• Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving an Excel Report which contains HTML tags  RSS feed

 
Poornima Beth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
We have a weblogic application in which there is a requirement to generate Excel Report with a particular format for records in the database.
We are generating the Excel Report with HTML tags in following way.

The ExcelReportGenerator.java has the following code snippet-

PrintWriter out = null;
/* This is the string which is generated with HTML tags in format.
<html><body><head> <style>.xl26 {mso-style-parent:style0; mso-number-format:\\@;}</style></head> <table border='1'> All the Report data
</table></body></html>
*/
String reportString = ExcelReportGenerator.getReportAsString(
reportHolder);

/*
* Set the report type as Excel format
*/
response.setContentType("application/vnd.ms-excel;charset=UTF-16");
response.setHeader("content-disposition",
"attachment;filename=VEHICLE CONFIGURATION REPORT.xls");
out = response.getWriter();
out.print(reportString);
out.flush();
out.close();

When running the application for �Export to Excel� functionality, a dialog pops up for save/open of file.
We can successfully save the save and open it.

Now, the problem is in the next step.
After opening the file in Excel, if we do a File-->Save As from Excel menu bar, the default extension for the file is now �HTML� and not .xls

We have to allow the user to be able to change the file name from the default �VEHICLE CONFIGURATION REPORT.xls� . But the �Save As� does not let the user save the excel report back as .xls but defaults it to Web Page.

Any help for solving this would be appreciated.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, sounds like M$ trying to second guess people again :roll:

What have you tried so far to work around this? Maybe try adding a blank numerical cell to the start of the report that would not display anything in the spreadsheet but might fool Excel into thinking the document was more than just HTML.
 
Poornima Beth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, We tried options by changing the Content Type to 'download' and 'excel'.
But none of them worked

Thanks for your suggestion, We tried it, but still no luck in resolving the issue.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!