I want to download an excel file saved from a path and write a new sheet with some data into it.And download this to the user.
Here is what I tried.Iam just reading the file and downloading it as it is.But it fails.
String uploadedFileName = "sampleFile.xls";
String propertiesPath = "D:/upload/"; // for local testing
FileInputStream fis = new FileInputStream(propertiesPath+ uploadedFileName);
logger.info(fis);
HSSFWorkbook workbook=new HSSFWorkbook(fis);
fis.close();
FileOutputStream out = null;
try {
out = new FileOutputStream("D:/download/codeFrame_1.xls");
workbook.write(out);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
out.close();
out=null;
}
fileName = "codeFrame_1.xls";
fileInputStream = new FileInputStream("D:/download/codeFrame_1.xls");
logger.info("created new file stream");
returnvalue="SUCCESS";
return returnvalue;
I want the excel file read and must be able to create a new sheet and downloaded in a folder.