awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
365 stars 78 forks source link

saveWorkbook corrupts .xlsx file with sheet names containing "&" character #539

Open pkohvaei opened 2 years ago

pkohvaei commented 2 years ago

Hello,

Here I explain how I see the problem:

Steps to Reproduce the Problem

  1. With wb <- loadWorkbook(my_file_path) I can view the following:

`

Sheet 1: "BioSafety"
Custom row heights (row: height)
 1: 15.5, 3: 25.5, 12: 15, 31: 13.5, 32: 13.5 

Sheet 2: "Project Info & Notes"
Custom row heights (row: height)
 3: 39, 20: 26.5, 24: 52.5 
Custom column widths (column: width)
  2: 21.88, 3: 35.18, 5: 39.18, 6: 59.58, 7: 18.58, 8: 17.38, 10: 76.38, 11: 11.18
 ...

`

  1. With saveWorkbook(wb, my_new_path, overwrite = T) I get a prompt when trying to open the new file in Excel:

The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt.

  1. This is a workbook with 12 sheets, 2 containing "&" in their names. If I delete those two, saveWorkbook() works fine.

sessionInfo()

Thank you,