ExportDataTableAsString after RecalculateFormula throws Exception

I have stumbled upon a situation where Aspose will handle something slightly different than Excel

If you look at the attached Excel file, you will find two sheets. The second sheet 'Sheet2' contains formulas that reference cells on the first sheet 'Sheet1'. The interesting thing is that the first formula on the second row of 'Sheet2' contains the formula '='Sheet1'!A2:B2. Even though this is not really a valid formula, Excel will still return the value of the first cell in the range - which is A2 in this case. Exporting out this sheet as DataTable will also successfully generate a datable - with the value in the second row for the cell in quesiton being 'A2'.

However, if you open the Excel file via Aspose, call RecalculateFormula, and then but try exporting to a Datable, you get an "Unable to cast object of type 'System.Object[][]' to type 'System.String'." exception. The item cauing the exception is the cell mentioned above that contains the cell reference to the range. The stack trace for the error shows that this error is coming out of the .StringValue off of the individual cell that is being called by ExportDataTableAsString.

I've attached the sample Excel file and here is the code

string excelFileNameAndPath = "c:\\RecalculateProblem.xls";

string licenseFile = SurveysConfiguration.GetSection().AsposeLicenseFilePathAndName;

License license = new Aspose.Cells.License();


Workbook workbook = new Workbook();



System.Data.DataTable sheetTable = workbook.Worksheets["Sheet2"].Cells.ExportDataTableAsString(0, 0, 2, 5);


Thank you for considering Aspose.

I tested your scenario with your provided code, template file and the latest version of Aspose.Cells and it works fine. Please try the attached latest version of Aspose.Cells and if you still face any problem, please create a sample application and post it here. We will check it soon.

Thank You & Best Regards,