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

Free Support Forum - aspose.com

Aspose Cells in Java is causing formulas to appear as #NAME?

I have the following code, listed below, it seems like for some formulas, the result that appears in the cell when I open the XLS is #NAME?.. if I go to the cell, click fx then click the tick, it fixes this, but it’s a bit laborious to do this for each cell. Can you tell me what’s causing it?

Can’t aspose just accept it’s a formula and set it as a formula?

Is there any workaround?

I’m using Java Cells version 17.10

Here’s my code, I’ve attached the resultant file below.

public static void main(String[] args) throws Exception{
Workbook excel = new Workbook();

Cells cells = excel.getWorksheets().get(0).getCells();

Cell cell = cells.get(0, 0);

cell.putValue(“Hello”);

cell = cells.get(“B1”);

cell.putValue(12);

cell = cells.get(0, 2);

cell.putValue(-1.234);

cell = cells.get(“D1”);

cell.setFormula("=B1 + C1");

Cell c1 = cells.get(“b2”);

c1.setFormula("=EXPON.DIST(4,5,TRUE)");

excel.calculateFormula(true);

Object v1=c1.getValue();

Cell c2 = cells.get(“b3”);

c2.setFormula("=SUM(AVERAGE(b1,c1), b1)");

excel.calculateFormula(true);

Object v2=c2.getValue();

try {
    excel.save("numberone.xls", SaveFormat.XLSX);

}
catch(Exception ex){
String g=“error”;

}
}

numberone.xls.zip (6.6 KB)

@mimecast

Thanks for using Aspose APIs.

Please change the given line into this. i.e. remove dot from the formula name

c1.setFormula("=EXPONDIST(4,5,TRUE)");

and it will fix your issue.