2

I am using Apache POI and Java 8 to generate excel from a existing template which has multiple sheets in it. This is a simple JavaFX based Desktop application which reads the excel file template and deletes sheets based on user input. For some reason when my code deletes a particular sheet I get the following error when I try to open the excel file after my program completes creating the Excel file:

We found a problem with some content in xyz.xlsm. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes. 

Errors were detected in file 'C:\LTDrive2_4\Excel\TwoPieceOBS_2019_08_15_12_01_33.xlsm'

removedRecords:
Removed Records: Table from /xl/tables/table79.xml part (Table)
Removed Records: Table from /xl/tables/table103.xml part (Table)
Flame
  • 6,663
  • 3
  • 33
  • 53
kula sekhar
  • 107
  • 1
  • 6

1 Answers1

1

I faced similar issue in my project. I was able to resolve it by check the cells in other sheets to see if they were referencing the tables or cells in the sheet which is being deleted. After modifying all the cell so that they do not have any dependency on the sheet being deleted, issue was resolved.

For example:

Sheet which was being deleted had the following formula in the cell.

=IF(ISNUMBER([@XYZ]),[@deg]/[@XYZ]," ")

Other sheet (probably a copy paste of the above sheet) had the formula.

=IF(ISNUMBER(Table726245820619242[@XYZ]),Table726245820619242[@deg]/Table726245820619242[@XYZ]," ")

If you notice there is Table726... in the formula which was causing the problem.

Once I corrected the formula so that does not have any such dependency then the issue was resolved.

Sai Haridass
  • 344
  • 2
  • 11