title: How to fix "We found a problem with some content in 'abc.xlsm'. Do you want us to try to recover as much as we can?
body: <p>I have the following method (<code>createAdditionalSheetsInExcel</code>) in my code which tries to create additional sheets for a particular scenario (<code>runOutputNumber &gt; 1</code>). It ends up creating an excel but the problem is when you try to open the excel you end up getting the following errors:</p>
  
  <p>The <code>workBookObj.cloneSheet(index,sheetName)</code> throws no errors in the java code but when I try to open the excel file I get the following errors:</p>
  
  <p>I tried to remove the formatting for the table in the sheet and then the error disappears. So it must be something to do with the format of the table inside the sheet. </p>
  
  <pre><code>private static void createAdditionalSheetsInExcel(String tempOutputFileName, String outputFileName, int runOutputNumber) throws IOException {
  
      FileInputStream fileIn = new FileInputStream(tempOutputFileName);
      XSSFWorkbook workBookObj = new XSSFWorkbook(fileIn);
      workBookObj.setWorkbookType(XSSFWorkbookType.XLSM);
  
      runOutputNumber = 2;//Hard coded for clarification
      if (runOutputNumber &gt; 1) {
  
          int initialNoOfSheets = workBookObj.getNumberOfSheets();
  
          for (int runIndex = 2; runIndex &lt;= runOutputNumber; runIndex++) {
  
              for (int index = 0; index &lt; initialNoOfSheets; index++) {
                  XSSFSheet sheet = workBookObj.getSheetAt(index);
  
                  String sheetName = sheet.getSheetName().trim()
                                      .substring(0, sheet.getSheetName().length() - 1) + runIndex;
                  workBookObj.cloneSheet(index, sheetName);
              }
          }
      }
  
      FileOutputStream fileOut = new FileOutputStream(outputFileName);
      workBookObj.write(fileOut);
  
      fileOut.close();
      workBookObj.close();
      deleteTempExcel(tempOutputFileName);
  }
  </code></pre>
  
  <p>Error when the excel tries to open:</p>
  
  <p>We found a problem with some content in 'abc.xlsm'. Do you want to try to recover as much as we can? If you trust the source of this workbook, click Yes. </p>
  
  <p>Error: After opening the excel file:</p>
  
  <p>Repaired Records: Table from /xl/tables/table1.xml part (Table)</p>