| Author |
Output of numbers to Excel
|
Bob Thackray
Greenhorn
Joined: Jun 17, 2003
Posts: 1
|
|
Hi, I am using setContentType("application/msexcel") to direct output to an excel spreadsheet for display. This works fine for text fields, but all fields that it thinks are numbers are truncated, ie: 000200 becumes 200 I need to display this as a text field ( as 000200). I have tried prefixing the string with a single ' but this just displays in excel as a character. How do I format the fells as text ? Thanks.
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
|
Try setting the format of the Excel cell to text. Then it should retain the format.
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
If you use a library to create the Excel spreadsheet, you can specify the cell format. I've used HSSF (horrible spreadsheet format) which is available from Apache. HSSF
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Wendal Park
Ranch Hand
Joined: Aug 28, 2001
Posts: 39
|
|
There is an ugly solution ... well I should say a "close-enough" solution: Try to wrap any fields (text) with either '' or "", then automatically Excel will treat them as normal text and display them as they are. But unfortunately they would appear as "000200" in the cells showing also the quotes. But if you can bear with this, then you don't spend extra time in learning to use a new package.
|
MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
|
 |
 |
|
|
subject: Output of numbers to Excel
|
|
|