cell.isErrorValue() inconsistent with cell.getType()


#1

Hi,

Sample code:

Workbook workbook = new Workbook("error.xlsx");
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.get(0);
for (int r = 0; r < 2; r++) {
    Cell cell = worksheet.getCells().get(r, 0);
    String name = CellsHelper.cellIndexToName(cell.getRow(), cell.getColumn());
    System.out.println(name + ", formula: " + cell.isFormula() + ", error value: " + cell.isErrorValue() + ", type: " + cell.getType());
}

The output, using Aspose Cells for Java, version 19.8.6, is as following:

A1, formula: true, error value: true, type: 2
A2, formula: false, error value: false, type: 2

Note that for cell A2, Aspose Cells indicates that the cell has no error value.
But at the same time, the cell type is com.aspose.cells.CellValueType#IS_ERROR.

This seems contradictory.

Kind regards,
Taras

error.zip (6.4 KB)


#2

@TarasTielkes,

Thanks for the sample code and template file.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found that for cell A2, Aspose.Cells indicates that the cell has no error value (which is right), but the cell type is retrieved as com.aspose.cells.CellValueType#IS_ERROR which is not right. I have logged a ticket with an id “CELLSJAVA-43009” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.


#3

Hi @Amjad_Sahi,

Cell A2 does have an error value. For example, try to use a formula like =LEN(A2) from a different cell - what result do you get?

Kind regards,
Taras


#4

@TarasTielkes,

Well, I guess the value “#N/A” in cell A2 is taken as string value which is not retrieved/calculated from a formula. Anyways, let us analyze the issue first in details.


#5

@TarasTielkes,
Cell.IsErrorValue was designed for some users’ special requirement and purpose. As the document of this API denotes, this method only checks the calculated value of formula and only returns true for the cell which is formula and the calculated value is an Error. Now that A2 is not a formula, so the result of it is false.

Anyways, this method does lead confusion and it is only used for few users and scenarios. So we may obsolete it later. Commonly you should use Cell.Type to check cell’s value type.