Sedang Disiapkan

222971 Excel File Download

Technical Specs: I'm running Tomcat 5.5 on a Windows machine. Running Java 1.5. This problem is in the main servlet.

Problem: I am converting HTML tables into an actual Microsoft Excel file, with the .xls extension. This option is more detailed than a CSV file, and does formatting and colors. That's not the problem, I have that working just fine. I can create the Excel file and I save it in a folder. I create a random number to name the file, so the generated Excel file is ultimately saved in the folder /WEB-INF/savedReports/[url removed, login to view]

The problem I'm facing is how to forward the request so that the person generating the report will download the Excel file properly. I accomplished this with a CSV file by using this code:

String tableHTML = [url removed, login to view]("tableHTML");

String csv=[url removed, login to view](tableHTML);

[url removed, login to view]("APPLICATION/OCTET-STREAM");

[url removed, login to view]("Content-Disposition", "attachment;filename=\"[url removed, login to view]\"");

PrintWriter out = [url removed, login to view]();

[url removed, login to view](csv);

[url removed, login to view]();


However, it's a different structure with Excel, because I have a file generated, not a String. As you see in the sample above, with a CSV file I can flush the CSV string into the output stream. However, you can't do that with an Excel file.

The limitations I face are this:

a) The generated files contain confidential information that no one else should be able to access

b) When a user clicks on the link to download the Excel file, it should pop up the dialog to Save or Open the Excel file.

Kemahiran: Semua Boleh, Java

Lihat lagi: string problem, m string, java and excel, how to create web application in java, files will not download, extension colors, java flush, how to microsoft excel, how do i save, flush java, how write technical report, web java servlet, technical specs, t write a technical report, servlet, save to excel, pop goes, open file, java+excel, java excel, file folder, excel to html, Excel to Access, Excel report, excel java

Tentang Majikan:
( 2 ulasan ) Round Rock, United States

ID Projek: #1969206