Free Support Forum - aspose.com

CellValueType option missing

Hi, In aspose.cells the CellValueType enum has limited set of values. like IS_BOOL, IS_DATE_TIME, IS_ERROR, IS_NULL, IS_NUMERIC, IS_STRING, IS_UNKNOWN.

It does not have any thing for currency. I need to check if the cell value type is currency and do certain processing. If the file contains a cell with type as currency and if i try to get its cellValueType then i get it as 4 i.e. Number. Can you add the IS_CURRENCY option? or is there any workaround?

Thanks & Regards,

Rohan Naik

Hi,


Well, in MS Excel, data (that is inserted/stored in the cells) can be any one of the main generic types, e.g Number, DateTime, String, Boolean etc. The currency data/values are actually Number data type, so once you evaluate the data as Number, you have to further check/evaluate the cell’s formatting type by yourself whether it is currency or decimal or others. I think you may also make use of the following methods of Style object. You may try the following options:
e.g
1) Style.getNumber() --> it will return numeric constant. For currency, it might be any one: 5,6,7,8, 37,38,… etc. Please check the table in the document for complete reference about the constant values of the different data:
http://www.aspose.com/docs/display/cellsjava/Setting+Display+Formats+of+Numbers++and++Dates

2) Style.getCustom() -->it will return the custom string for the data.

3) Cell.getStringValue() --> you need to evaluate it by yourself if the data is of currency value or contains “$” etc.

Thank you.


Hi, I tried cell.getStyle().getNumber() . But for both number and currency format it gives the value 0. So this wont help. I need some way of identifying if my cell is formatted as General or Number or Currency. Is there any other way?

Regards,

Rohan Naik

Hi,


Please make sure the data is inserted a numeric type in your template sheet’s cell and not as General that you are retrieving for numeric or currency data, could you attach your template Excel file here, we will check your issue soon.

Thank you.