Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadWorkbook has corrupted workbook if sort exists #524

Open
bsleik opened this issue Nov 27, 2020 · 1 comment
Open

loadWorkbook has corrupted workbook if sort exists #524

bsleik opened this issue Nov 27, 2020 · 1 comment

Comments

@bsleik
Copy link

bsleik commented Nov 27, 2020

Expected Behavior

wb <- loadWorkbook("testCorrupting.xlsx") #that has a sort as part of a filter
saveWorkbook(wb,"testCorrupted.xlsx", overwrite=TRUE)

open testCorrupted.xlsx - should not come up as corrupt.

Actual Behavior

open testCorrupted.xlsx - Excel says it is corrupted.

clearing the autoFilter field of the worksheet object before saving resolves it, but drops the filter and sort:

wb <- loadWorkbook("testCorrupting.xlsx") #that has a sort as part of a filter
wb[["worksheets"]][1][[1]][["autoFilter"]]
[1] "<autoFilter ref="A1:C1"><sortState ref="A2:C5"><sortCondition ref="B1"/>"

wb[["worksheets"]][1][[1]][["autoFilter"]] <- character(0)

also the following works as it is only the sort that causes an issue:

wb[["worksheets"]][1][[1]][["autoFilter"]] <- "<autoFilter ref="A1:C1"/>
saveWorkbook(wb,"testCorrupted.xlsx", overwrite=TRUE)

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)
testCorrupting.xlsx

  1. Have a spreadsheet with a filter added and a column sorted as in testCorrupting.xlsx

  2. do the following in R

wb <- loadWorkbook("testCorrupting.xlsx")
saveWorkbook(wb,"testCorrupted.xlsx", overwrite=TRUE)

  1. Attempt to open testCorrupted.xlsx

sessionInfo()

  • Version of openxlsx: openxlsx_4.2.3
  • Version of R: 3.6.1 (2019-07-05)
@JMPivette
Copy link

I had exactly the same issue.
Can you report this bug to the "active" openxlsx repository : https://github.com/ycphs/openxlsx/issues

It looks like awalker89/openxlsx is the old repository and is not active anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants