Problem
When creating multiple pivot tables in the same workbook, the second pivot table uses the field definitions from the first pivot table instead of its own fields.
Steps to Reproduce
// Create two pivot tables with different row fields
workbook.addPivotTable({
name: 'HCP Summary',
sourceSheet: dataSheet,
rows: ['Last name', 'SAP ID', 'Territory', 'Territory manager', 'Region'],
columns: ['Triggering event'],
values: ['Count'],
metric: 'sum'
});
workbook.addPivotTable({
name: 'Site Summary',
sourceSheet: dataSheet,
rows: ['Site (from Novocure SAP)', 'Territory', 'Territory manager', 'Region'],
columns: ['Triggering event'],
values: ['Count'],
metric: 'sum'
});
Expected Behavior
- First pivot table should use: Last name, SAP ID, Territory, Territory manager, Region
- Second pivot table should use: Site (from Novocure SAP), Territory, Territory manager, Region
Actual Behavior
- First pivot table correctly uses: Last name, SAP ID, Territory, Territory manager, Region
- Second pivot table INCORRECTLY uses: Last name, SAP ID, Territory, Territory manager, Region (same as first!)
Debug Output
Adding console.log shows the correct arrays are being passed:
DEBUG: Creating pivot table "HCP Summary update" with rows: [ 'Last name', 'SAP ID', 'Territory', 'Territory manager', 'Region' ]
DEBUG: Creating pivot table "Site Summary update" with rows: [ 'Site (from Novocure SAP)', 'Territory', 'Territory manager', 'Region' ]
But examining the generated xl/pivotTables/pivotTable2.xml shows it doesn't contain "Site (from Novocure SAP)" at all.
Root Cause
There appears to be shared/cached state inside ExcelJS that isn't being cleared between pivot table creations. The second addPivotTable() call is likely reusing field mappings or cache from the first pivot table.
Impact
This makes it impossible to create multiple pivot tables with different field configurations in the same workbook, which is a common use case for reporting.
Problem
When creating multiple pivot tables in the same workbook, the second pivot table uses the field definitions from the first pivot table instead of its own fields.
Steps to Reproduce
Expected Behavior
Actual Behavior
Debug Output
Adding console.log shows the correct arrays are being passed:
But examining the generated
xl/pivotTables/pivotTable2.xmlshows it doesn't contain "Site (from Novocure SAP)" at all.Root Cause
There appears to be shared/cached state inside ExcelJS that isn't being cleared between pivot table creations. The second
addPivotTable()call is likely reusing field mappings or cache from the first pivot table.Impact
This makes it impossible to create multiple pivot tables with different field configurations in the same workbook, which is a common use case for reporting.