dcsimg
Excel output with leading zeroes
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bonnie_Smyre
Posted On:   Tuesday, September 25, 2001 03:13 PM

I have a servlet that outputs an MS Excel file. It works great except for one thing. One column has SSNs. SSNs, of course, look numeric but can have leading zeroes. When the Excel result page appears, it cuts off those leading zeroes.

If I were manually creating the spreadsheet, I'd change the properties to that column to text before importing that data. Is there any way that I can force that to happen in my servlet? Or is there any other way that I can make the leading zeroes stay?

Thanks!

Re: Excel output with leading zeroes

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, September 25, 2001 05:29 PM

Bonnie,

You can use the java.text.DecimalFormat class:


Format df = new DecimalFormat("000000000");

System.out.println(df.format(12345));

About | Sitemap | Contact