awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
364 stars 79 forks source link

Error when loading workbook with multiple pivot tables sharing common data sources #377

Open Havimo opened 6 years ago

Havimo commented 6 years ago

Expected Behavior

Workbook is loaded as normal in the global environment

Actual Behavior

Workbook fails to load with this error message :

Error in sprintf("<Relationship Id=\"rId%s\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition\" Target=\"pivotCache/pivotCacheDefinition%s.xml\"/>",  : 
  arguments cannot be recycled to the same length

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)

It seems this problem occurs when there are 3 (or more) pivot tables with 2 of them sharing a common data sources. Please see very simple .xlsx file attached mre_openxlsx.xlsx

sessionInfo()

anurag3290 commented 4 years ago

Try using 'xlsx' package instead of 'openxlsx'. Alternatively, can try : wb = xlsx::loadWorkbook(base_file)