question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Location of pivot cache parts inside xlsx file

See original GitHub issue

Description

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: pivotcache2

Expected

When one generates a file in Excel, pivot cache parts are in this location: pivotcache

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
igiturcommented, Jul 8, 2019

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.

0reactions
twsouthwickcommented, May 30, 2020

Feel free to reopen if it still needs to be explored

Read more comments on GitHub >

github_iconTop Results From Across the Web

Location of pivot cache parts inside xlsx file #612
When creating a new .xlsx file with a pivot table in Excel and saving it, the pivot cache parts (specificially the PivotCacheDefinitionPart and ......
Read more >
Pivot Cache in Excel - What Is It and How to Best Use It
Go to Analyze –> Pivot Table –> Options. Pivot Cache in Pivot Table Excel - Analyze Options ; In the Pivot Table Options...
Read more >
Parsing Pivot Cached Records while loading Excel file
The Pivot Cache is held inside the memory of Microsoft Excel. You cannot see it but that is the data the Pivot Table...
Read more >
Pivot Cache in one one workbook, Pivot table in another ...
A PivotCache is the memory cache for a PivotTable report. This memory cache is needed for the PivotTable to function in the first...
Read more >
Can't Open Pivot Table Source file
Open the excel archive with an archiver, and go to xl\pivotCache\_rels folder. From the pivotCacheDefinition1.xml.rels file (and from all other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found