Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to generate real excel reports

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lalitha Perumal
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Access generating actual .xls files for you?
If so is it writing them to disc on the server?
 
Lalitha Perumal
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic