Skip to content

Crash when opening a file containing a pivot table created with MS Excel and containing negative numbers. #2189

@rlclaro

Description

@rlclaro

Read and complete the full issue template

Do not randomly delete sections. They are here for a reason.

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • Yes
  • No

If you answered No, please test with the latest development build first.

Version of ClosedXML

0.102.1

What is the current behavior?

I have a table that contains negative values, I create the pivot table from this data, I save the excel and when I open it with MS excel I get error Repaired Records: PivotTable report from /pivotCache/pivotCacheDefinition1.xml part (PivotTable cache)

image

The error happens only with MS Excel, with Libre Office or Open Office it does not happen.

What is the expected behavior or new feature?

Being able to open excel correctly

Is this a regression from the previous version?

I tested with version 0.101.0 and the error disappeared.

Reproducibility

This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.

Without a code sample, it is unlikely that your issue will get attention. Don't be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.

Code to reproduce problem:

 // Create the pivot table, using the data from the table
 IXLPivotTable pivotTable = workSheet.PivotTables.Add($"{table.Name}_Pivot", workSheet.Cell(2, 1), table.AsRange());
 pivotTable.ClassicPivotTableLayout = true;
 pivotTable.SetLayout(XLPivotLayout.Tabular);
 pivotTable.AllowMultipleFilters = true;
 pivotTable.DisplayCaptionsAndDropdowns = true;
 pivotTable.ShowExpandCollapseButtons = true;
 pivotTable.AutofitColumns = true;
 pivotTable.PrintExpandCollapsedButtons = true;

 /// Add pivotTable.RowLabels

 var pivotField = pivotTable.RowLabels.Add(value);
 pivotField.SetLayout(XLPivotLayout.Tabular);
 
/// Add Values and Formula

 var pivotValue = pivotTable.Values.Add(value);
 pivotValue.SummaryFormula = XLPivotSummary.Average;

 workSheet.Columns().AdjustToContents();
  • I attached a sample spreadsheet. (You can drag files on to this issue)

    The generated excel contains sensitive data

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:load/saveProblems related to loading or saving.bugfeature:pivot-tablePivot tables (NOT pivot table styles)triagedChecked and and verified that it is actionable (not dup, has required info)waiting-author-responseIssues awaiting author's response or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions