Closed radiance88 closed 1 year ago
Thanks, confirmed. In the created file xl/workbook.xml
contains multiple entries of extLst
. That is not supposed to happen and Excel most likely does not like that. I guess I imported that because we were losing some extLst entries, now we have them duplicated. Oh boy
A fix for now:
# import your Slicer_test.xlsx
wb <- openxlsx::loadWorkbook("~/gh_issue_313.xlsx")
# keep only the last extLst (the openxlsx created one in this case)
wb$workbook$extLst <- wb$workbook$extLst[2]
# works in ms365
openxlsx::saveWorkbook(wb, "test.xlsx", overwrite = TRUE)
For some reason openxlsx
decided, that it wants some extLst
(most likely due to the slicer found on a sheet), though we failed to check if there are extLst elements we could merge with or even overwrite. Appending seems like the worst idea in this case as it leads to broken files for Excel. If bitten by this: they work fine with LibreOffice.
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Describe the bug I created a simple excel file "Slicer_test.xlsx", with some random data, a pivot table and a slicer. Nothing wrong when using R openxlsx. I simply use loadWorkbook to load it and then saveWorkbook to save it as another file. Then when I open the new file it says 'We found a problem with some content in the file. Do you want us to try to recover". If I click "Yes", it says "The workbook cannot be opened or repaired because it is corrupt" To Reproduce
wb <- loadWorkbook("Slicer_test.xlsx") saveWorkbook(wb,"Slicer_test_saved.xlsx")
Expected behavior I expect Excel should be able to open the output file with no problem.
Screenshots
Example files If applicable, add example files to help explain y Slicer_test.xlsx our problem (
openxlsx
and/orExcel
created files)