How to add row to the end of a worksheet

I'm trying to figure out how to add a row to the end of a worksheet. InsertRow will only add a before the last row in the worksheet. And using InsertRow with a value greater than IWorksheet.Rows.Length is ignored.


3 Replies

BP Bhuvaneswari P Syncfusion Team April 11, 2008 04:25 AM UTC

Hi Brian,

Thanks for the update.

If your intention to insert row after the end of the used range, then please use mySheet.UsedRange.End.Row. Please use the below code snippet to insert row after used range row:
[C#]
MessageBox.Show("Before insert :total rows Edited:" + mySheet.UsedRange.End.Row.ToString());
//To insert the row after specified some row index
mySheet.InsertRow(mySheet.UsedRange.End.Row,1, ExcelInsertOptions.FormatDefault );
MessageBox.Show("After insert: total rows:" + mySheet.UsedRange.End.Row.ToString());

Here is the sample for your reference:


http://websamples.syncfusion.com/samples/XlsIO.Windows/I42808_2/main.htm


or If your intention is to insert the row at the end of the worksheet, then this is not possible to get the end of the row in the worksheet using our XlsIO API's.

Please let me know if I am missing anything.

Best Regards,
Bhuvana




BR Brian Richards April 11, 2008 12:59 PM UTC

My needs are to do exactly what you say that I can't do.



BP Bhuvaneswari P Syncfusion Team April 18, 2008 12:03 PM UTC

Hi Brian,

As we said in the last update, it is not possible to add row to the end of a worksheet.

Please let me know if you have any other questions.

Regards,
Bhuvana


Loader.
Up arrow icon