From 9650119ad5443a2b8c522d95df12b9a5343491e4 Mon Sep 17 00:00:00 2001 From: Milou Brand Date: Thu, 22 Oct 2020 15:44:44 +0100 Subject: [PATCH 1/3] import data *removed silly comments --- R/WorkbookClass.R | 4 ++-- R/loadWorkbook.R | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/WorkbookClass.R b/R/WorkbookClass.R index e575ed0..5bfe955 100644 --- a/R/WorkbookClass.R +++ b/R/WorkbookClass.R @@ -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){ @@ -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 diff --git a/R/loadWorkbook.R b/R/loadWorkbook.R index 1aa2790..d7fc091 100644 --- a/R/loadWorkbook.R +++ b/R/loadWorkbook.R @@ -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 @@ -322,7 +322,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE){ ## workbook rels wb$workbook.xml.rels <- c(wb$workbook.xml.rels, - sprintf('', rIds, 1:length(pivotDefXML)) + paste0('') ) From 597126039ad427e452e45500ae70701ab97fb1a4 Mon Sep 17 00:00:00 2001 From: Milou Brand Date: Thu, 22 Oct 2020 15:56:22 +0100 Subject: [PATCH 2/3] import data *removed silly comments --- R/loadWorkbook.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/loadWorkbook.R b/R/loadWorkbook.R index d7fc091..b9f6610 100644 --- a/R/loadWorkbook.R +++ b/R/loadWorkbook.R @@ -277,7 +277,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE){ wb$pivotTables.xml.rels, perl = TRUE, ignore.case = TRUE))) ## pivot cache records - tmp <- unlist(regmatches(pivotCacheRecords, gregexpr("(?<=pivotCache/pivotCacheRecords)[0-9]+(?=\\.xml)", pivotCacheRecords, perl = TRUE, ignore.case = TRUE))) + tmp <- unlist(regmatches(pivotCacheRecords, gregexpr("(?<=pivotCache/pivotCacheRecords)[0-9](?=\\.xml)", pivotCacheRecords, perl = TRUE, ignore.case = TRUE))) pivotCacheRecords <- pivotCacheRecords[tmp %in% cache_keep] ## pivot cache definitions rels From f0767ade3218d8e042c2b89ded94d192e8f38efb Mon Sep 17 00:00:00 2001 From: Milou Brand Date: Thu, 22 Oct 2020 15:56:47 +0100 Subject: [PATCH 3/3] load data --- R/loadWorkbook.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/loadWorkbook.R b/R/loadWorkbook.R index b9f6610..d7fc091 100644 --- a/R/loadWorkbook.R +++ b/R/loadWorkbook.R @@ -277,7 +277,7 @@ loadWorkbook <- function(file, xlsxFile = NULL, isUnzipped = FALSE){ wb$pivotTables.xml.rels, perl = TRUE, ignore.case = TRUE))) ## pivot cache records - tmp <- unlist(regmatches(pivotCacheRecords, gregexpr("(?<=pivotCache/pivotCacheRecords)[0-9](?=\\.xml)", pivotCacheRecords, perl = TRUE, ignore.case = TRUE))) + tmp <- unlist(regmatches(pivotCacheRecords, gregexpr("(?<=pivotCache/pivotCacheRecords)[0-9]+(?=\\.xml)", pivotCacheRecords, perl = TRUE, ignore.case = TRUE))) pivotCacheRecords <- pivotCacheRecords[tmp %in% cache_keep] ## pivot cache definitions rels