-
Notifications
You must be signed in to change notification settings - Fork 79
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 pivot tables #387
Comments
I think error 1 might be the same as my open issue (#377). Could you please explain how you bypassed it? |
Yes, it's the same problem. You can avoid the error by creating an aditional sheet whit the extra pivot tables that you need (multiple of pivotCacheDefinition) to load the workbook and before saving it again, delete this sheet. It's hard to know how many tables are necessary, it depends on the number of caches. Usually, there is one pivotCacheDefinition per sheet that is the source of at least one dynamic table. I hope that this helps you with your problem. If not, do not hesitate to ask again. |
I have experienced exactly the same issues as @isabelgc . I think that error 1 could be solved using paste() or similar function instead of sprintf() function. I have tried @isabelgc 's possible solution to error 2 and it worked like a charm! Please, I would like to request it to be included in next releases. Thank you for helping me to solve the problem! |
Expected Behavior
Loading the workbook in the environment, saving it and opening it without errors or without loss of information such as dynamic tables.
Actual Behavior
Error 1: If the number of pivot tables is not a multiple of pivotCacheDefinition's number, an error is returned.
Error 2: But once I solve this problem creating the required number of pivot tables (multiple of pivotCacheDefinition length), when I save the workbook and I try to open it, there is an error that is deleting random pivot tables that were at the workbook before. This happens because there are more than 9 pivotCacheDefinition.
Steps to Reproduce the Problem
(please attach an example xlsx file if possible)
template_error.xlsx
template_error_save.xlsx
Loading the file "template_error.xlsx" and saving it, you can reproduce the error on file "template_error_save.xlsx"
Adding one pivot table in "template_error.xlsx" and loading the workbook, you will have the first error I described about multiples
Possible solution
We realized that making some little changes, error 2 is resolved. We only had to add "+" in regular expression of:
cache_keep <- unlist(regmatches(wb$pivotTables.xml.rels, gregexpr("(?<=pivotCache/pivotCacheDefinition)[0-9](?=\\.xml)", wb$pivotTables.xml.rels, perl = TRUE, ignore.case = TRUE)))
if(length(tables) > 0){ table_inds <- which(grepl("tables/table[0-9].xml", ws_rels))
pivotNode <- workbook.xml.rels[grepl("pivotCache/pivotCacheDefinition[0-9].xml", workbook.xml.rels)]
sessionInfo()
The text was updated successfully, but these errors were encountered: