Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

rendering JSP in XLS format

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a jsp which i am rendering as an xls. I need to convert the numbers as text format.

for example: If i have a number as 00010345 it should be displayed as is when exported to an xls. Currently the number is displayed as, 10345 (Without the zeros)

Hope it was descriptive enough. Please help.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you rendering a JSP as an excel file?? I don't know how you are actually doing it, but once I needed to create excel files and I created then using Apache POI library for that. Since it is not clear to me how you are rendering your JSP as an excel file, I wonder how you have a number like 00010345 in java. If you store that value in a numeric type, it will automatically remove the leading zeros. So if you have that value as a String in java, maybe you should render it as a string in your excel file...
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If i have a number as 00010345 it should be displayed as is when exported to an xls. Currently the number is displayed as, 10345 (Without the zeros)


Excel can do this (as can the libraries used for creating proper XLS files - mainly Apache POI and jExcelApi). But since you mention JSPs, I'm pretty sure that you're not creating an XLS file, but rather some text file that you're trying to have Excel open by setting the content type; is that correct? If so, then this can't be done.
 
Benjamin Samuel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I 'm pretty sure that you're not creating an XLS file, but rather some text file that you're trying to have Excel open by setting the content type; is that correct?




Yes, thats exactly what i have done. I am not creating a binary file and data writing into it.
I tried to display the field as a formula field[by prefixing and'=' sign], and tried appending a space [ ] to convert it to string format. But this is not how they want it to be done. please let me know if you are aware of any other workaround.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it would be useful to know how "they" want "it" to be done, and what "it" actually is. As I said, the original problem requires creating (and streaming) an actual XLS file, and that can't be done in a JSP - you need to use a servlet.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic