poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <dan...@nuix.com>
Subject Re: Formatting cells in HSSF
Date Mon, 25 Jun 2007 00:17:12 GMT
On Friday 22 June 2007 22:18:35 Fallows, Andrew wrote:
> I'm not entirely sure what you mean. If you mean modifying the data in
> the file so that it's treated as a string, that's not ideal, because I'd
> like to avoid requiring modifications to the xls files themselves -
> every added step per file is one less benefit from automation. I'll do
> that if it comes to it, but I'd rather find a way in the program.

Actually I was suggesting storing these values as strings in the first place 
(when entering them in the spreadsheet the first time.)

What wasn't clear from your original post was whether you were creating data 
to be read by Excel, or whether you were processing data created by Excel.

If you're creating data on your end to be read by Excel, you just need to set 
the value in as a string instead of using a numeric value.  If you're 
creating it in Excel, then your options are to prefix the value with a ' to 
make it a string value, or manually format it however you want.

Keep in mind though that if you use numeric values, eventually you *will* be 
bitten by the precision bug, if the number has enough digits.  The only way 
to be 100% sure that precision is being kept is by using integer values 
(which I don't think Excel can even do... correct me if I'm wrong) or by 
using strings.  Plus you'll generally lose leading zeroes unless you use a 
format like "000000000000" to work around that.  I always found it much 
easier to use actual string values when the values were IDs rather than 
numeric values where maths was required.

Daniel


-- 
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://nuix.com/                               Fax: +61 2 9212 6902

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


Mime
View raw message