Free Support Forum - aspose.com

Invalid formula error for .xlsx file format - Aspose Cells(7.1.0.4) using java

Hello,

Please find the attached excel file.

1) In the attached excel, in Sheet 'TEST', i have the following formula in the cell C8.

=MIN(Sheet2!E14*'Test Page'!$E$54,Sheet2!D14*3%) + MIN(Sheet2!G14*'Test Page'!$E$54,Sheet2!D14*3%)

the following java code(with Aspose.Cells 7.1.0.4 and correct libs) works fine when i execute with the above excel.

Workbook workbook = new Workbook("Book-formula.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("TEST");
Cells cells = worksheet.getCells();
System.out.println("value:"+cells.get("C8"));

2) now i copied the following formula as it is in the same cell(C8),

=MIN(Sheet2!E14*'Test Page'!$E$54,Sheet2!D14*3%) +
MIN(Sheet2!G14*'Test Page'!$E$54,Sheet2!D14*3%)

The following exception comes when i execute the above java code.

Exception:
com.aspose.cells.CellsException: Error in Cell: C8-Invalid formula."MIN(Sheet2!E14*'Test Page'!$E$54,Sheet2!D14*3%) +
MIN(Sheet2!G14*'Test Page'!$E$54,Sheet2!D14*3%)".

Note: both above formulas works fine if the file of type .xls.

Any idea why I would get these exceptions?

Thanks,
Sreeram

Hi,

Thanks for your posting and using Aspose.Cells for Java.

Please download and use the latest version:
Aspose.Cells
for Java v7.3.2.1

and see if it resolves your issue.

I tried your file with the following code but I was unable to reproduce your exception. Please provide us your complete sample runnable code replicating this exception.

We will look into it and help you asap.

Java


String filePath = “F:\Shak-Data-RW\Downloads\Book-formula.xlsx”;


Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.getWorksheets().get(“TEST”);

Cells cells = worksheet.getCells();

System.out.println(“value:”+cells.get(“C8”));


Cell cell = cells.get(“D10”);

cell.setFormula(cells.get(“C8”).getFormula());


workbook.calculateFormula();


workbook.save(filePath + “.out.xls”);