title: JAVA APACHE POI: Getting a "We found a problem with some content in *.xlsx. Do you want us to try to recover it as much as we can" error
body: <p>We're trying to generate excel files, and I'm running into the above error when trying to execute this code - </p>
  
  <p>I've tried using <code>CreationHelper</code>, and also tried <code>FileOutputStream</code>. But, nothing seems to work. We're using apache poi - 4.0.1</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>XSSFWorkbook xssfWorkbook = excelDownloadService.createSheetForBudget(type, campaignId, duration);
  
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              xssfWorkbook.write(bos);
  
              response.setContentType("application/vnd.ms-excel");
              response.setHeader("Content-Disposition", "attachment; filename=Budget.Report_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMddyy")) + ".xlsx");
              xssfWorkbook.write(response.getOutputStream());
  
              xssfWorkbook.close();
              response.getOutputStream().flush();
              response.getOutputStream().close();</code></pre>
  </div>
  </div>
  </p>