title: Java POI - convert Workbook to File
body: <p>I need to return a Workbook but converted to Java <code>File</code> object.
  For now I only know how to write the Workbook to the disk with <code>workbook.write(outputStream)</code>. However, I want to return the <code>File</code> object in order to use it directly for further processing (uploading to Amazon).</p>
  <p>My code:</p>
  <pre><code>public File addErrorColumnToExcel(MultipartFile file, HashMap&lt;Integer, String&gt; errors, int newColumnIndex) throws IOException {
      Workbook workbook = null;
      Sheet sheet = null;
      Row row;
      Cell newErrorCell;
      String errorText;
  
      try {
        workbook = new XSSFWorkbook(new BufferedInputStream(file.getInputStream()));
        sheet = workbook.getSheetAt(FIRST_SHEET_INDEX);
      } catch (IOException e) {
        logger.error(&quot;cannot get the file: &quot; + file.getOriginalFilename() + e);
      }
  
      //do some logic
  
      return workbook; //but I need to convert this to a java File
    }
  </code></pre>