Here is my code snippet
try{
response.setHeader("Content-Disposition", "attachment;filename=someName.xls");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(1);
row.createCell((short)1).setCellValue(1.2);
row.createCell((short)2).setCellValue("Rajesh Kumar ");
row.createCell((short)3).setCellValue(true);
FileOutputStream fileOut = new FileOutputStream("C:/Excels/workbook.xls");
wb.write(fileOut);
fileOut.close();
response.getOutputStream().flush();
} catch ( Exception ex ) {
ex.printStackTrace();
}
The above snippet creates file successfully on hard disk. However whenever the excel sheet is opened it is blank ?
What is the reason ? What can be solution ?