1

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.

karthika R
  • 11
  • 1
  • "It fails" is not diagnostic. You need to include at least the action configuration, what you're actually doing to trigger the download, and what actually happens. Please see the [How to Ask](https://stackoverflow.com/help/how-to-ask) page. – Dave Newton Jun 18 '19 at 12:57
  • okie.. first time user ..i figured it out.Thanks for the help – karthika R Jun 21 '19 at 05:14
  • It might help you https://stackoverflow.com/a/18634352/573032 – Roman C Jul 14 '19 at 22:11

0 Answers0