poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Beardsley <markbrd...@tiscali.co.uk>
Subject Re: Issue with retrieving the existing values in a cell
Date Thu, 03 Feb 2011 11:30:04 GMT

Had the chance to look at the code you posted this morning and wanted to
mention the use of the CellUtil.createCell() method. A couple of times you
use this method and encapsulate a numeric value into a String object so that
it can be passed to this method. Now, I am no expert, but I think that the
createCell() method is setting the cell's type to text (general). Owing to
this. Excel will flag an error when it opens the file telling you that it
has found a number formatted as text. Rather than rely on the createCell()
method, it might be better to use just a couple of additional lines of code
and do the job yourself;

   Cell cell = row.createCell(index);

where index contains the number of the column the cell should occupy.

The setCellValue() method is overloaded to accept paratemers of many
different types and it will set the cells type for you. So, the call I made
above to setCellVlaue(34399) will have set the cells type as numeric and
it's value to 34399, avoiding the error flagging when the file is opened
using Excel.


Mark B
View this message in context: http://apache-poi.1045710.n5.nabble.com/Issue-with-retrieving-the-existing-values-in-a-cell-tp3367484p3369138.html
Sent from the POI - User mailing list archive at Nabble.com.

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

View raw message