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

Error loading and saving workbook with filters #456

Open
ColinTB opened this issue Mar 14, 2019 · 1 comment
Open

Error loading and saving workbook with filters #456

ColinTB opened this issue Mar 14, 2019 · 1 comment

Comments

@ColinTB
Copy link

ColinTB commented Mar 14, 2019

Expected Behavior

When loading a workbook with filters and then resaving the workbook the file should not become corrupt. I think it might be simplest to just have the filter removed, rather than attempt to apply to filter to possibly new data.

Actual Behavior

File becomes corrupt and any sheets with filters appear blank.

These are the excel corruption warning when trying to open the file.

image

image

Steps to Reproduce the Problem

  1. Set path
    wb_path <- "PATH TO FOLDER/test.xlsx"

  2. Create simple workbook
    wb <- createWorkbook() addWorksheet(wb, sheetName = "test") writeData(wb, sheet = "test", data.frame(a = 1:2)) saveWorkbook(wb,file = wb_path, overwrite = T)

  3. Open the workbook, add a filter to Column A and from the dropdown filter for for only 2

  4. Load the worbook and try to update the data on the tab with the filter
    wb <- loadWorkbook(wb_path) writeData(wb, sheet = "test", data.frame(a = 1:3)) saveWorkbook(wb,file = wb_path, overwrite = T)

  5. When I try to open the update workbook I get the warnings shared above and the "test" tab is now blank (Example corrupted workbook)

sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

other attached packages:
[1] openxlsx_4.1.0

@mschwartsman
Copy link

I wish there were a proper solution, but I've found a workaround. Load the workbook and call openxlsx::removeFilter(wb, sheet = <sheets_with_filters>) before proceeding.

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