Free Support Forum - aspose.com

Calculation error : invalid cast

Hi Aspose team,

I received an invalid cast error, how can i solve the problem?

cell formula

=IF(MAX(C25:J25)-C25=0;C25;C25&" to "&MAX(D25:J25))

I sent the file by mail.

thanks for your help.

Hi,

Please replace the ';' with ','.

I tried the following code using a sample template file and it works fine:

Workbook workbook = new Workbook();
workbook.Open("d:\\test\\calcBook1.xls");
Worksheet worksheet = workbook.Worksheets[0];
Aspose.Cells.Cell cell = worksheet.Cells[0, 1];
cell.Formula = "=IF(MAX(C25:J25)-C25=0,C25,C25& \" to \"&MAX(D25:J25))";
workbook.CalculateFormula();
MessageBox.Show(cell.StringValue); // gives the correct value.
workbook.Save("d:\\test\\calcBook2.xls");

Which version you are using? Please try the latest version.

Thank you.

I test with your file and don’t find the problem. Maybe it’s a bug in old versions. Please try this attached version.