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

Loading Existing Workbook with Slicers Corrupts on Save #504

Closed
thdougher opened this issue Dec 28, 2022 · 3 comments
Closed

Loading Existing Workbook with Slicers Corrupts on Save #504

thdougher opened this issue Dec 28, 2022 · 3 comments

Comments

@thdougher
Copy link

Hello, I was testing slicer functionality with both tables and pivot tables and noticed that any workbooks created with the wb_save function would always be corrupted. Repairing the workbook would lead to the removal of the slicer objects. I created a minimal reproducible example to limit the process to simply loading the workbook and immediately saving the loaded workbook. However, these steps still did not prevent the corruption from occurring.

Please see below for the input file that contains three tabs. The "data" tab contains the source data, the "Pivot" tab contains the pivot table object with two slicers, and the "Table" tab contains the table object with two slicers on the same fields as the "Pivot" tab.
On workbook repair of the output file, both slicers linked to the pivot table were removed. However, one slicer linked to the table remained.

openxlsx2 slicer corruption - input.xlsx

library(openxlsx2)

wb <- wb_load(paste0(tempdir(), "\\", "openxlsx2 slicer corruption - input.xlsx"))
wb_save(wb, paste0(tempdir(), "\\", "openxlsx2 slicer corruption - output.xlsx"),overwrite=TRUE)

I used the latest github version of the package. Session info is below:

#> R version 4.2.2 (2022-10-31 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] openxlsx2_0.4.1.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.9        rstudioapi_0.14   knitr_1.41        magrittr_2.0.3   
#>  [5] R.cache_0.16.0    R6_2.5.1          rlang_1.0.6       fastmap_1.1.0    
#>  [9] stringr_1.5.0     styler_1.8.1      highr_0.10        tools_4.2.2      
#> [13] xfun_0.36         R.oo_1.25.0       cli_3.5.0         withr_2.5.0      
#> [17] htmltools_0.5.4   yaml_2.3.6        digest_0.6.31     lifecycle_1.0.3  
#> [21] zip_2.2.2         purrr_1.0.0       vctrs_0.5.1       R.utils_2.12.2   
#> [25] fs_1.5.2          glue_1.6.2        evaluate_0.19     rmarkdown_2.19   
#> [29] reprex_2.0.2      stringi_1.7.8     compiler_4.2.2    R.methodsS3_1.8.2

I would greatly appreciate any consideration for this issue, and please let me know if any additional information would be beneficial.
Thanks again for your development efforts into this package.

@JanMarvin
Copy link
Owner

JanMarvin commented Dec 28, 2022

Hi @thdougher , thanks for the report. I have opened a PR #505 could you check if that solves your issue?
Edit: you could try something like remotes::install_github("JanMarvin/openxlsx2#505")

@thdougher
Copy link
Author

Hello @JanMarvin,
Thanks for the edit as I am still new. I am confirming that no corruption occurred and the slicers remained intact. Thanks for looking into this issue so quickly.

@JanMarvin
Copy link
Owner

🎉 thanks for checking, guess I'll merge it tomorrow

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