from aspose 24.6 onwards for some inputs the formulas give wrong results.
it seems to be related to using match with an {} array literal.
The following code demonstrates the issue:
import com.aspose.cells.CellsHelper;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
public class AsposeMatchArrayLiteral {
public static void main(String[] args) throws Exception {
Workbook workbook = new Workbook();
workbook.getSettings().getFormulaSettings().setCalculateOnOpen(false);
Worksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getCells().get("A1").setValue("a");
worksheet.getCells().get("B1").setValue("b");
worksheet.getCells().get("C1").setValue("c");
worksheet.getCells().get("D1").setValue("d");
worksheet.getCells().get("E1").setValue("e");
worksheet.getCells().get("F1").setValue("match result");
worksheet.getCells().get("A2").setValue(80);
worksheet.getCells().get("B2").setValue("Some text");
worksheet.getCells().get("D2").setValue("A152");
worksheet.getCells().get("A3").setValue(81);
worksheet.getCells().get("B3").setValue("Some text");
worksheet.getCells().get("D3").setValue("A123");
worksheet.getListObjects().add("A1", "F3", true);
worksheet.getCells().get("E2").setFormula("=IF(ISNUMBER(MATCH(MID([@d],3,1),{\"4\"},0)),IF(IF((NOT(([@b]=\"\"))),NOT(([@c]=\"\")),(TRUE)),\"\"),\"expected\")");
worksheet.getCells().get("E3").setFormula("=IF(ISNUMBER(MATCH(MID([@d],3,1),{\"4\"},0)),IF(IF((NOT(([@b]=\"\"))),NOT(([@c]=\"\")),(TRUE)),\"\"),\"expected\")");
worksheet.getCells().get("F2").setFormula("=MATCH(MID([@d],3,1),{\"4\"},0)");
worksheet.getCells().get("F3").setFormula("=MATCH(MID([@d],3,1),{\"4\"},0)");
workbook.calculateFormula();
System.out.println("Running in Aspose version " + CellsHelper.getVersion());
// in 24.6+ incorrect result based on A152 input:
System.out.println("Expecting 'expected', got: " + worksheet.getCells().get("E2").getValue());
// correct result based on A123 input:
System.out.println("Expecting 'expected', got: " + worksheet.getCells().get("E3").getValue());
// in 24.6+ incorrect result based on A152 input:
System.out.println("Expecting '#N/A', got: " + worksheet.getCells().get("F2").getValue());
// correct result based on A123 input:
System.out.println("Expecting '#N/A', got: " + worksheet.getCells().get("F3").getValue());
// workbook.save("/tmp/result.xlsx");
}
}
In this sample both E2 and E3 should result in “expected”, but from 24.6 onwards E2 results in false
.