If you're able to control your input, you can prefix the values in those
columns with a single quote, to ensure they're treated as a string.  If
you can't control this, perhaps someone else can figure this out. 

> -----Original Message-----
> From: Fallows, Andrew [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, June 21, 2007 6:24 AM
> To: [email protected]
> Subject: Formatting cells in HSSF
> 
> Hi all,
> 
> I've just started using HSSF, and I can tell that it's going 
> to be very helpful to me - I work with Excel files 
> frequently, and automating tasks through Java will be much 
> easier if I can access the data directly from .xls files, as 
> opposed to manually collecting and formatting data before 
> processing it (which is still faster than doing the whole 
> thing manually, but less...faster). So I appreciate that this 
> product exists.
> 
> However, I've run into a stumbling block that I haven't found 
> the answer for in the How-to, the Quick Guide, or the 
> Javadocs. I'm hoping this is the right groups to be in, and 
> that you can help me out.
> 
> In the file I'm currently working with, one of the columns 
> contains a series of alpha-numeric codes, most of which are 
> all numerals. And the trouble I'm having is that when I print 
> these codes out, those which are all numerals get treated as 
> large numbers and printed in scientific notation (i.e. 
> 9.9152516E7). I need to look at them as just a series of 
> digits, since they are not, in the traditional sense, numbers.
> 
> I have tried using HSSFCellStyle with the following code:
> 
> HSSFCellStyle style = wb.createCellStyle(); 
> style.setDataFormat(wb.createDataFormat().getFormat("@"));
> 
> and calling curCell.setCellStyle(style); when I iterate over 
> the codes, just before I print them.
> 
> And I've used "0", "#,##0", and "General" in place of "@", 
> but none of those have worked. Is there a DataFormat that 
> will do what I need it to do, or are then other steps necessary?
> 
> Many thanks in advance,
> Andrew Fallows
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to