Skip to main content

One post tagged with "Add a column"

View All Tags

· 4 min read
Burcu Evren

Adding a column at the end of an Excel spreadsheet is a common need that arises from various practical scenarios. Whether it's for better data organization, appending new information, performing calculations, conducting data analysis, or enhancing visualization and reporting, the ability to seamlessly add a column at the end proves to be invaluable.

In this blog, we will explore an efficient method to accomplish this task using Excel's 'insert column' node.

How to Setup?

To begin, Log in to your Robomotion workspace. If you haven't registered yet, you can create your workspace from the provided link.

About Core Excel Package

The Excel package offers a range of features and functionalities to work with spreadsheets, such as create and copy sheets, setting formulas, delete or add columns and more.

Note: This flow specifically utilizes Core Excel. It is important to note that if you attempt to perform the same operations using the MS Excel Package, it may result in errors. Therefore, it is recommended to stick with Core Excel to ensure the smooth execution of the flow.

How to add a column at the end in Excel?

To add a column at the end in Excel, you can follow these steps:

  1. Utilize the 'insert column' node: Use the 'insert column' node, which allows you to seamlessly add a new column to your Excel file.

  2. Locate the last column: Start by using the 'get row' node to find the last column in the current Excel file. This can be achieved by extracting the length of the msg.row object, which is the output of the 'get row' node.

  3. Add the column: Once you have determined the position of the last column, use the 'insert column' node to add the new column to the Excel file. This operation ensures that the column is placed at the end of the spreadsheet.

  4. Save your changes: Remember to save the Excel file after adding the column to preserve your modifications and ensure that they are retained for future use.

Flow Steps

  1. ‘Inject’ node is used to initialize the flow.

  2. Additionally, two crucial variables are defined using a "function" node. The first variable, 'msg.excel_path,' allows you to specify the path of the Excel file to be used within the flow. The second variable, 'msg.lastColumnData,' is where you define the name of the column you wish to add.

Code for Set Excel Properties Function Node:

msg.excel_path = ""; // Give the excel path here
msg.lastColumnData = [""]; // Give the column name here

Each insert column node is used to insert a column.
The variable msg.lastColumnData is the column name to be added.
return msg;
  1. 'The 'Open Excel' node is utilized to open the designated Excel file, with the 'msg.excel_path' variable serving as its input.

  2. The 'Get Row' node is utilized to determine the last column in an Excel file, with the row number being the input for the 'Get Row' node.

  3. The 'Get Length' node is used to obtain the length of the 'msg.row' object, which is the output of the 'Get Row' node, in order to determine the last column.

Note: To utilize the 'Get Length' node, you will need to download the 'Robomotion.Object' package. The images below demonstrate the steps to download the package.

Package Icon

Install Icon

  1. In the 'Prepare Column' function node, Excel columns are defined. The last column is determined using the 'msg.len' variable, which represents the output of the 'Get Length' node, along with the following code.


var array = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
var len = msg.len;
msg.lastColumn = array[len]
return msg;

NOTE: The array variable defined in the 'Prepare Column' node is in the range of A-Z. If the column you are adding exceeds this range, you will need to define additional Excel columns to this variable, such as 'AA', 'AB', and so on.

  1. The column name defined is appended to the last column found using the 'Insert Column' node.

Insert Column Node Options

  1. The Excel file is saved to the designated Excel path using the 'Save Excel' node, with the 'msg.excel_path' variable serving as the input.

  2. The saved Excel file is closed using the 'Close Excel' node.

  3. The 'Stop' node is utilized to halt the flow of execution.

Add Column in Last Flow

Here you can access the complete flow by clicking on the following link: