How to add new line to excel file in C #

I need to insert a new line under the first line. using the code below, what do I need to add to do this?

Excel.Application excelApp = new Excel.Application(); string myPath = @"Data.xlsx"; excelApp.Workbooks.Open(myPath); // Get Worksheet Excel.Worksheet worksheet = excelApp.Worksheets[1]; int rowIndex = 2; int colIndex = 2; for (int i = 0; i < 10; i++) { excelApp.Cells[rowIndex, colIndex] = "\r123"; } excelApp.Visible = false; 

Thanks:)

+6
source share
1 answer

Suppose you want to add to the third line:

 Range line = (Range)worksheet.Rows[3]; line.Insert(); 
+11
source

Source: https://habr.com/ru/post/943980/