poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Defoort <filip...@cirquedigital.com>
Subject Re: bug in cell.setCellType(Cell.CELL_TYPE_NUMERIC) (POI 3.6)
Date Thu, 07 Jan 2010 18:33:29 GMT
On Wed, Jan 6, 2010 at 11:55 PM, MSB <markbrdsly@tiscali.co.uk> wrote:
> Yes, that would work for your requirement Filip but I can easilly imagine
> another using say that the String value "$2,500" should be converted to a
> number and a format should be generated and applied automatically to the
> cell so that they did not lose the dollar sign and comma separator - and is
> this really the function of a setCellYtpe() method? I think that we could
> convincingly argue that if you try to convert a cell whose type is text or
> string into a numeric cell (for example) then a warning should be issued
> that information may be lost. In my opinion, it will not be possible to
> catch and handle every little requirement, so the conversion of the value
> should be performed and the user ought to be warned that changes may occur
> to the appearence of the cell.

It probably wouldn't be that hard to loop over the data formats and
see which ones fit and convert. A warning would indeed be nice or an
extra parameter to the setCellType() method.

E.g. setCellType(Cell.TYPE*, boolean convert)

In either case, calls to setCellType() shouldn't fail.

On a somewhat related topic: I'm really surprised that calls to
.getStringCellValue() fail if the type of a cell is not string. It'd
seem logical to me to return a string representation of the cell's
value (or to have another method called .getCellDisplayValue() or
something like that so a user has a single method they know they can
always call to get the value of a cell without needing switch
statements all over the code to handle variations).

- Filip

To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message