aspose file tools*
The moose likes Servlets and the fly likes How to generate real excel reports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to generate real excel reports" Watch "How to generate real excel reports" New topic
Author

How to generate real excel reports

Lalitha Perumal
Greenhorn

Joined: Apr 22, 2005
Posts: 11
Hi All,

I am generating excel report using servelt.We set the following header details as,

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; name=\"report.xls\" filename=\"report.xls\"");

The problem is that I couldn't import the excel files generated in this way in MS-Access, I am getting the message that 'Please check that the file exists and is in correct format.

Please help me to get real excel reports without using any plugins.

Thanks in Advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
It seems to me there are two disinct areas to check, the actual data format being created and the transmission of the response.
Have you tested your .xls file generation methods outside the servlet environment? Once you are sure that the byte stream being generated makes a readable .xls file, then you can look at the servlet part of the problem.

Bill


Java Resources at www.wbrogden.com
Lalitha Perumal
Greenhorn

Joined: Apr 22, 2005
Posts: 11
Hi Bill,
I didn't check my .xls file generation methods other than servlet. Since ours is a web application, i didn't try it from other technologies
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Is Access generating actual .xls files for you?
If so is it writing them to disc on the server?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Lalitha Perumal
Greenhorn

Joined: Apr 22, 2005
Posts: 11
Hi Souther,

I'm suspecting that my servlet is not generating real excel file,even if we set the header, content_type as 'application/vnd.ms-excel'.
I'm using html <table> tag to draw excel cells and append them in StringBuffer object, finally I'm writing this object in the response.

I could able to generate excel report, but not the real one since I couldn't import that excel file in MS-Access, but original excel files we could.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39577
    
  27
Excel can open files containing HTML tables, but since those aren't XLS files, Access can't import them.

Setting the Content-Type does not make the servlet output into Excel files; it merely asserts that the output is in fact an Excel file. It's the responsibility of the servlet to then generate XLS files. Libraries like POI and jExcelAPI can do this.

I'm not too familiar with Access, but I think it can import CSV files, which are much easier to generate.


Ping & DNS - updated with new look and Ping home screen widget
 
 
subject: How to generate real excel reports
 
Similar Threads
Downloading Excel file (containg BAR Chart) from JSP
generating reports in servlets?? MAHA please helppppp
How to make an excel sheet rendered on browser read only?
Apache POI :Export to xls(Coloured Cell) not working in MS Excel
Generate Filter Cells For Excel Sheets Using POI HSSF