• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Format data exported to Excel from JSP

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are currently using JSP to load data to an excel by setting the content type header in the JSP.

Inside the JSP we are just creating a regular HTML table with rows and columns which excel uses to populate cells.

What we really want to do is control the Page setup of the created excel for example changing the style of sheet from Potrait to Landscape etc.

Is this possible directly from JSP?

Thanks
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Piyush Jain:

Is this possible directly from JSP?



The real question is whether this is possible when importing HTML into Excel. It really has nothing to do with the JSP per se.

As such, this is actually an Excel question and I'm going to move it along to the General Computing forum.
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you find that what you wish to do isn't possible by feeding Excel HTML (I have no idea, but I'd be surprised if you could), you'll probably need to explore the use of tools that generate Excel format rather than HTML.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've had some success with such things by taking an Excel spreadsheet, formatting it the way I'd like it to look, and then saving it as HTML from Excel. Then, you can take the generated HTML, and use it to see what you need to output from your JSP. It's not exactly simple, and it doesn't let you do everything, but I've been able to produce some nice looking reports this way.

Hope this helps.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand your question so this answer may not help. If you are trying to produce and return an actual Excel file:

- recent versions of Excel can use an XML format. I've seen examples in several JSP or Struts "cookbook" type books. It's what you expect -- you set the content-type in the page directive and then kick out XML instead of HTML.

- if you need to support an earlier version of Excel, you can use a library like Apache "POI". It's not JSP per-se, although I guess you could wrap it into a custom tag. With POI you create and populate a HSSFWorkbook, write it to a ByteArrayOutputStream, and then return that in your response with the appropriate content-type.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.codetoad.com/asp_excel.asp

This link may help, read down through all the comments for the full story. This works great in asp, but I have not tried it with a jsp yet. The idea is to create the spreadsheet in excel, then save it in html format. Open the html file that excel created and insert your code.

In asp, I just create a link that calls this "asp" page. It prompts the user to either open the file, or save it to their system.

Have you looked at the Jakarta POI project?

Hope this helps.
Eric

[ March 25, 2006: Message edited by: Eric Gero ]
[ March 25, 2006: Message edited by: Eric Gero ]
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic