title: Java - Read excel, modify then save to a new file
body: <p>I have it currently working so that my application is generating the content, then saving the information into an excel file, this is working as expected using the below code</p>
  <pre><code>public void writeExcel(ClassManager cm, String fn, ErrorManager em) throws FileNotFoundException, IOException {
      // Get classes
      classes = cm.getClasses();
      String fileName = (!&quot;&quot;.equals(fn)) ? fn : &quot;temp.xlsx&quot;;
     
      // Create Rows
      setupRows();
      
      File currDir = new File(&quot;.&quot;);
      String path = currDir.getAbsolutePath();
      String fileLocation = path.substring(0, path.length() - 1) + fileName;
  
      FileOutputStream outputStream = new FileOutputStream(fileLocation);
      workbook.write(outputStream);
      outputStream.close();
      workbook.close();
  }
  </code></pre>
  <p>the setupRow function calls several other functions, all setup the same as below</p>
  <pre><code>public void setupRowTemplateName() {
      int start = 2;
      Row row = sheet.createRow(1);
          
      for (int i = 0; i &lt; classes.size(); i++) {
          // Get class and template details
          Classes c = classes.get(i);
          Template t = c.getTemplate();
          
          // Create cell
          Cell cell = row.createCell(start);
          
          // Set contents
          if(t != null) {
              cell.setCellValue(t.getName());
          }
          
          start++;
      }
  }
  </code></pre>
  <p>I'm trying to adjust the saving so that it takes an excel file, adds the information to that, then saves as a new file (i.e: Take file &quot;Codes Template.xlsx&quot;, add data, save as another filename.</p>
  <p>So far I have</p>
  <pre><code>public void writeExcelReplace(ClassManager cm, String fn, ErrorManager em) throws FileNotFoundException, IOException {
      File currDir = new File(&quot;.&quot;);
      String path = currDir.getAbsolutePath();
      String fileLocationOpen = path.substring(0, path.length() - 1) + &quot;Codes Template.xlsx&quot;;
      
      FileInputStream inputStream = new FileInputStream(new File(fileLocationOpen));
      workbook = WorkbookFactory.create(inputStream);
      sheet = workbook.getSheetAt(0);
      
      // Get classes
      classes = cm.getClasses();
      String fileName = (!&quot;&quot;.equals(fn)) ? fn : &quot;temp.xlsx&quot;;
     
      // Create Rows
      setupRows();
      
      String fileLocation = path.substring(0, path.length() - 1) + fileName;
  
      inputStream.close();
      FileOutputStream outputStream = new FileOutputStream(fileLocation);
      workbook.write(outputStream);
      outputStream.close();
      workbook.close();
  }
  </code></pre>
  <p>This is taking the content from the &quot;template&quot; file and saving it to the new file, but none of the content from setupRows is being added</p>