Free Support Forum - aspose.com

Issues with CellValueType

Hi,

Please find the attached sample class and Excel file.

Scenario :
a. All the excel worksheets are generated from a same template excel worksheet.
b. The value set to cell is always a String type of value.

Issues :

For non calculated cell (B5)

[Note : Value of B5 is same in all worksheets and is 200511]

The CellValueType is not same in all the worksheets, though the worksheets are created from same template worksheet
Cell Value Type for [Sheet : RDN7][Cell : B5] is DOUBLE
Cell Value Type for [Sheet : RDN9][Cell : B5] is DOUBLE
Cell Value Type for [Sheet : RDN11][Cell : B5] is INT
Cell Value Type for [Sheet : RDN12][Cell : B5] is INT
Cell Value Type for [Sheet : RDN13][Cell : B5] is DOUBLE

For calculated cell (E6)
E6 is been evaluated from formula.
cell.getValueType() is returning NULL.
Cell Value Type for [Sheet : RDN7][Cell : E6] is NULL
Cell Value Type for [Sheet : RDN9][Cell : E6] is NULL
Cell Value Type for [Sheet : RDN11][Cell : E6] is NULL
Cell Value Type for [Sheet : RDN12][Cell : E6] is NULL
Cell Value Type for [Sheet : RDN13][Cell : E6] is NULL

I am summing up the same cells from all the worksheets to generate AggregationWorksheet.

I am processing these cells based on the CellValueType and I am getting ClassCastException due to first issue and Null value due to second issue.

Note : I dont want to apply the formula for aggregating the cell due to performance issues.

Quick reply is appreciated.
Thank You.
Kailas




Hi,

Thanks for providing us the template file.

For calculated cell (E6)
E6 is been evaluated from formula.
cell.getValueType() is returning NULL.

Please either open your template file into MS Excel manually and save it. Now use Aspose.Cells APIs to use your code, it will work fine.

or.... add a line to your code i.e..,

............

Workbook workbook = new Workbook();

workbook.open("D:/ASPOSE TEST/f9w94p023k1r.xls", FileFormatType.EXCEL2003);

workbook.calculateFormula();

for (int i = 0; i < sheetNames.length; i++)
{

.............

For non calculated cell (B5)
[Note : Value of B5 is same in all worksheets and is 200511]

...as cellvaluetype returns Double, INT...

We will check and figure it out soon.

Thank you.

Hi Kailas,

For your scenario

a. All the excel worksheets are generated from a same template excel worksheet.


Would you please give us your template excel sheet and code to generate the fifth row(for cells A5,B5,C5,...) of all sheets in the result file f9w94p023k1r.xls? In this result file, data type flags of cell B5 in sheet RDN11 and RDN12 are different from that of other sheets, that is, in sheet RDN11 and RDN12, the flag denotes the type as int but in other sheets as double.

By the way, to process cells based on CellValueType, you should cast the value object according to value type, such as, when CellValueType.DOUBLE, the value object should be cast as Double, when CellValueType.INT, the value object should be cast as Integer, and so on. For correspondence of value object's class type to value type, please refer to the javadoc for Cell.getValue().