Write Excel

This adds the first worksheet to an ExcelWorksheet variable, creates a loop based on the number of rows given to it, inserting the values with each iteration.

This script will require adding using OfficeOpenXml; to the namespaces section.

ExcelWorksheet document = excelDocument.getWorkSheet(1);

for (int i=1;i<=NumberOfRows;i++)
{                               
      document.Cells[i, 1].Value=givenValue;
}

The ExcelWorksheet variable has to be open using the “Open excel workbook” action before initializing the C# script, otherwise it will not be a valid reference to an Excel Workbook.

After the C# script action, use “Close excel workbook” to save the changes made.

Last updated