ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
220 stars 74 forks source link

freezePane only works on document without previously freezed panes #423

Closed sjaustirni closed 4 months ago

sjaustirni commented 1 year ago

Describe the bug freezePane() does not freeze panes when called on a workbook which might have previously had panes freezed. Freezing panes therefore works on documents generated in-memory, but does not work consistently on documents loaded from disk.

When it works:

When it does not work:

To Reproduce 1) Generate a document with freeze panes:

wb <- createWorkbook("Kenshin")
addWorksheet(wb, "Sheet 1")
freezePane(wb, sheet=1, firstActiveRow = 2, firstActiveCol = 2)
saveWorkbook(wb, "freezedPanes.xlsx", overwrite = TRUE)

2) Open the document in Excel and confirm the first row and first column is freezed 3) (optionally) Unfreeze the panes in Excel GUI and save the document 4) Try to change the freezed panes:

wb <- loadWorkbook("freezedPanes.xlsx")
freezePane(wb, sheet=1, firstActiveRow = 3, firstActiveCol = 3)
saveWorkbook(wb, "freezedPanes.xlsx", overwrite = TRUE)

Expected behavior Upon opening the file in Excel, I expect the first two rows and first two columns be freezed.

Actual behaviour Freezed panels won't change. If you have removed the freezed panes in Excel GUI, upon running the second snippet you still won't have any panes freezed. If you have not removed freezed panes in Excel GUI, only the first row and first column will be freezed (that is, from running the first script)

Additional context The amount of previously or newly freezed panes and columns does not matter, at least from what I could see from my experimentation. Only the previously-freezed-panes state matters. I had previously suspected that the Excel program has changed the way of freezing the panes, which is currently unreadable to openxlsx, but that does not seem to be the case. Even if you skip step number 3, the bug is still there.

Software version

github-actions[bot] commented 5 months ago

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.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 7 days with no activity.