Insert a row in worksheet using aspose cell

I want to add a empty row in worksheet.

@amitahlawat

Thanks for using Aspose APIs.

Please use Worksheet.Cells.InsertRows() method for your needs. Please see the following sample code, its comments, input and output Excel files and screenshot for a reference.

The code inserts 10 empty rows starting from 3rd row.

Download Link:
Input and Output Excel files.zip (12.9 KB)

C#

// Load a template file.
Workbook workbook = new Workbook("sampleInsertRows.xlsx");

// Get the first worksheet in the book.
Worksheet sheet = workbook.Worksheets[0];

// Insert 10 rows at row index 2 (insertion starts at 3rd row)
sheet.Cells.InsertRows(2, 10);

// Save the excel file.
workbook.Save("outputInsertRows.xlsx");

Screenshot