We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ExportDataTableAsString is not exporting the last row

Hi Team,

while doing ExportDataTableAsString with the “worksheet.Cells.MaxRow” as total rows the its not returning the Last row. Please help if any one knows.
Ex: worksheet.Cells.ExportDataTableAsString(0,0,worksheet.Cells.MaxRow, 10, true);

Thanks in advance.


Thanks for your query.

The reason is Cells.MaxRow returns the last row index which contains data or formatting but the index is zero based. Suppose there are 10 rows in your worksheet, so when you use Cells.MaxRow it will return “9” (being zero based). But, you need to provide number of rows parameter as “10”. To cope with it, you will do add 1 row to the max row value. You may change the line of code as following:
Sample code:

worksheet.Cells.ExportDataTableAsString(0,0,worksheet.Cells.MaxRow + 1, 10, true);

Hope, this helps a bit.

Thank you.