Handling empty rows



when trying to read the excel file attached with ExportDataTableToString(), I get a DataTable with a total of 32 rows instead of 16. The last 16 rows have no valid values, meaning they’re empty in excel (no value visible).

When deleting the rows 17-32 in excel, saving the file and trying to read it again, everything seems to be fine. But how can I avoid that empty rows are exported to DataTable?

Kind regards,



Hi Michael,

How do you specify the parameters of ExportDataTableAsString method? Could you please post your code here?


Hi Laurence,

thanks for your reply. This is my code:

DataTable table = excel.Worksheets[0].Cells.ExportDataTableAsString(0, 0, excel.Worksheets[0].Cells.MaxRow+1, excel.Worksheets[0].Cells.MaxColumn+1);


MaxRow returns max row index of the cell at the bottom, no matter if the cell is blank or not.

I add new properties to return the max row index of the cell which contains data. Please try the following sample code with the attached fix:

DataTable table = excel.Worksheets[0].Cells.ExportDataTableAsString(0, 0, excel.Worksheets[0].Cells.MaxDataRow+1, excel.Worksheets[0].Cells.MaxDataColumn+1);


Hi Laurence,

thanks for you reply. I tested the fix and it works fine.



Hi Laurence,

after some tests I found out that sometimes the content of the cells gets scrambled. It seems that it can be any cell which scrambles and sometimes everything works fine. I did not change my code and with the previous install of Aspose.Excel everything was ok.

Can you help?



Hi Michael,

Please check http://www.aspose.com/wiki/default.aspx/Aspose.Excel/LicensingComponent.html
and http://www.aspose.com/wiki/default.aspx/Aspose.Excel/GarbageTextInWorksheet.html for reference.

It’s added in about two months before.


Thanks for the hint Wink Sourcesafe revealed that I removed the SetLicense() call last week…