public void saveReport( HttpServletRequest pRequest,
HttpSession pSession )
//get your own data, you can ignor this part.
HashMap map = getData( pRequest, pResponse, pSession );
Report report = new MyReport();
String reportData =
report.generateReportToString( (Hashtable)map.get( "header" ),
(Enumeration)map.get( "data" ) );
//set your report type
pResponse.setContentType( "application/vnd.ms-excel" );
//if you want to save the report as a file Force browser to show save as dialog and give default file name.
"attachment; filename="+DEF_REPORT_NAME );
pResponse.setContentLength( reportData.length() );
pResponse.getWriter().print( reportData );
I thought excel spreadsheets were in a proprietary, binary format. So how can the browser simply save the file as *.xls ? Simply making a file "filename.xls" make it an excel file ?
One way to solve this problem is to write to an Access database and export the table as an excel document.
Check this site out. They seem to have some JDBC drivers to manipulate excel documents.
P.S. e-mail your results