(Double) getValue() or getDoubleValue()

I am new to aspose.cell.

When I read the online ducument of retrieving data from a cell (http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/retrieving-data-from-cells.html) I found the code reads like this:

double d = ((Double)cell.getValue()).doubleValue();

I am curious to know if it brings any benefit (better performance?) than to use getDoubleValue:

double d = cell.getDoubleValue().doubleValue();

Thanks a lot.

Hi,

Thanks for your inquiry.

Well, Cell.getValue() returns an object value from which you may retrieve any type (e.g int, double, boolean, string, datetime etc.), whereas Cell.getDoubleValue() is only useful if you want to get a double value from the cell. Anyways, we will get back to you soon to further explain you if there is any (internal) performance perspective involved.

Thank you.

Hi,

If you are sure that all the data of cells on which you call:

double d = ((Double)cell.getValue()).doubleValue();

are double values, there is no difference whether you call as:

double d = cell.getDoubleValue().doubleValue();

However, if there are some cells that have Integer values, or some cells have been formatted as DATETIME, then calling:

double d = ((Double)cell.getValue()).doubleValue();

might cause ClassCastException. So, we think it would be better for you to use:

double d = cell.getDoubleValue().doubleValue();

Thank you.