I need to insert a new row below the first row. using the code below, what i need to add to make it done ?
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 :)
Select the entire row which you want to insert a blank row above, and press Shift + Ctrl + + keys together, then a blank row is inserted.
Sometimes you may want to add a blank row to your spreadsheet. Luckily, there is an easy keyboard shortcut for this: Ctrl+Shift+Plus. Simply click a row number to select a row, hold down the Ctrl and Shift keys, and press plus (+). Excel will then add a row above the selected row.
Suppose you want to add in the third line:
Range line = (Range)worksheet.Rows[3];
line.Insert();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With