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

Proposed fixes #520

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/WorkbookClass.R
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ Workbook$methods(writeSheetDataXML = function(xldrawingsDir, xldrawingsRelsDir,

## Check if any tables were deleted - remove these from rels
if(length(tables) > 0){
table_inds <- which(grepl("tables/table[0-9].xml", ws_rels))
table_inds <- which(grepl("tables/table[0-9]+.xml", ws_rels))

if(length(table_inds) > 0){

Expand Down Expand Up @@ -1915,7 +1915,7 @@ Workbook$methods(preSaveCleanUp = function(){

## Reordering of workbook.xml.rels
## don't want to re-assign rIds for pivot tables or slicer caches
pivotNode <- workbook.xml.rels[grepl("pivotCache/pivotCacheDefinition[0-9].xml", workbook.xml.rels)]
pivotNode <- workbook.xml.rels[grepl("pivotCache/pivotCacheDefinition[0-9]+.xml", workbook.xml.rels)]
slicerNode <- workbook.xml.rels[which(grepl("slicerCache[0-9]+.xml", workbook.xml.rels))]

## Reorder children of workbook.xml.rels
Expand Down
4 changes: 2 additions & 2 deletions R/loadWorkbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE){


# ## Check what caches are used
cache_keep <- unlist(regmatches(wb$pivotTables.xml.rels, gregexpr("(?<=pivotCache/pivotCacheDefinition)[0-9](?=\\.xml)",
cache_keep <- unlist(regmatches(wb$pivotTables.xml.rels, gregexpr("(?<=pivotCache/pivotCacheDefinition)[0-9]+(?=\\.xml)",
wb$pivotTables.xml.rels, perl = TRUE, ignore.case = TRUE)))

## pivot cache records
Expand Down Expand Up @@ -322,7 +322,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE){

## workbook rels
wb$workbook.xml.rels <- c(wb$workbook.xml.rels,
sprintf('<Relationship Id="rId%s" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" Target="pivotCache/pivotCacheDefinition%s.xml"/>', rIds, 1:length(pivotDefXML))
paste0('<Relationship Id="rId',rIds,'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" Target="pivotCache/pivotCacheDefinition',1:length(pivotDefXML),'.xml"/>')
)


Expand Down