Location of pivot cache parts inside xlsx file
See original GitHub issueDescription
When creating a new .xlsx file with a pivot table in Excel and saving it, the pivot cache parts (specificially the PivotCacheDefinitionPart
and PivotCacheRecords
parts) are saved to the ./xl/pivotCache/
location inside package.
When one generates pivot tables using the OpenXML SDK, these new parts are added to the ./pivotCache/
location. Notice that it does not fall under ./xl/
.
While the generated file isn’t corrupt and works with all spreadsheet clients, the discrepancy about the location of the parts does feel strange. It’s especially confusing when one opens an Excel-generated file using the OpenXML SDK where the file already contains pivot table parts and one adds new pivot table parts. The resulting file will have the original pivot table cache parts in the ./xl/pivotCache
location, but the newly added parts will be in the ./pivotCache/
location. Additionally, this is the only spreadsheet-related part (that I’ve noticed) that does not save to some location under ./xl/
.
Information
- .NET Target: .NET 4.7.2
- DocumentFormat.OpenXml Version: Commit 9d8629a7778c876e56b3c7e14c213b65f6f84ea0
Repro
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
namespace ConsoleApp1
{
internal class Program
{
private static void Main(string[] args)
{
using (var package = SpreadsheetDocument.Create("outputfile.xlsx", SpreadsheetDocumentType.Workbook))
{
var workbookPart = package.AddWorkbookPart();
workbookPart.AddNewPart<PivotTableCacheDefinitionPart>("rId2");
}
}
}
}
Observed
Notice location of result pivot cache parts:
Expected
When one generates a file in Excel, pivot cache parts are in this location:
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
I notice that in https://github.com/OfficeDev/Open-XML-SDK/blob/master/src/DocumentFormat.OpenXml/GeneratedCode/Packaging/PivotTableCacheDefinitionPart.g.cs#L85 the relative target path is defined as
../pivotCache
. But this is relative to the workbook part.I suspect someone treated this target path as if it’s relative one of the pivot tables that uses the pivot table cache definition.
Feel free to reopen if it still needs to be explored