Hi
I have written a simple code to generate a excel workbook from servlet using Apache POI.
But here I have to hardcode the excel name and path to be saved.
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@ page import="org.apache.poi.poifs.filesystem.POIFSFileSystem"%>
<%@ page contentType="application/vnd.ms-excel" %>
<%@ page import="java.io.*" %>
<%
try{
POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream
("c:\\excel\\rajesh1.xls"));
HSSFWorkbook wb=new HSSFWorkbook(fs);
FileOutputStream fileOut = new FileOutputStream(
"c:\\excel\\readingWriting.xls");
wb.write(fileOut);
fileOut.close();
out.println("Your excel file has been generated");
} catch ( Exception ex ) {
}
%>
But I have seen in web sites that if u wish to download an excel sheet, then on clicking on download link,
we get a pop-up which asks to save, view or cancel action.
If we choose save, a dialogue box appears where we can select path and give a name for our file.
How is this possible in my code above