Setting default Style on a cell (PivotFieldType.Row) in pivot table corrupts the file

Hello,

We at theTradeDesk are using heavily pivot tables. So far we were using Aspose.Cell (for C#) version 16.10.2, after upgrading to the newest version we noticed our pipeline started producing corrupted xlsx files. After investigating the issue we figured out that:

  • The latest version that produces valid xlsx files is: 20.04.0
  • With version 20.05.0 our builds fail
  • Starting with version 20.06.0 the produced xlsx files are corrupted

The corruption happens if the file contains a pivot table with cells of PivotFieldType.Row type. If one sets the style of such a cell using Style object created with default costructor (without setting any properties on the object) the resulting output xlsx file is corrupted.

To illustrate this issue I created following reproducer:

using System.Collections.Generic;
using Aspose.Cells;
using Aspose.Cells.Pivot;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TTD.Domain.Shared.Excel.UT
{
  [TestClass]
  public class AsposeCellRegressionTests
  {
    [TestMethod]
    public void Test3()
    {
      License AsposeLicenseFile = new License();
      AsposeLicenseFile.SetLicense( "Aspose.Cells.lic" );
      using ( var workbook = new Workbook() )
      {
        var columns = new List<string>() { "Column name 1", "Column name 2" };
        CreateDataSheet( workbook, columns );
        CreatePivotSheet( workbook, columns );
        workbook.Save( "/tmp/output.xlsx", SaveFormat.Xlsx );
      }
    }
      
    private void CreateDataSheet( Workbook workbook, List<string> columns )
    {
        var dataSheet = workbook.Worksheets.GetSheetByCodeName( "Sheet1" );
        for( int i = 0; i < columns.Count; ++ i )
        {
            dataSheet.Cells[ 0, i ].Value = columns[i];
            var sampleDataCell = dataSheet.Cells[ 1, i ];
            sampleDataCell.Value = "Sample value";
        }
        var dataSheetDataRange = dataSheet.Cells.CreateRange( dataSheet.Cells.FirstCell.Name, dataSheet.Cells.LastCell.Name );
        dataSheetDataRange.Name = "Data0";
    }

    private void CreatePivotSheet( Workbook workbook, List<string> columns )
    {
        var pivotSheet = workbook.Worksheets.Add( "Pivot1" );
        var pivotTableIndex = pivotSheet.PivotTables.Add( string.Format( "'{0}'!{1}", "Pivot1", "Data0" ), "A5", "Pivot" );
        var pivotTable = pivotSheet.PivotTables[ pivotTableIndex ];
        foreach( var column in columns )
        {
            pivotTable.AddFieldToArea( PivotFieldType.Row, column );
        }
        pivotTable.CalculateData();
        
        foreach ( var column in columns )
        {
          var cell = pivotTable.GetCellByDisplayName( column );
          if( cell == null )
            continue;
          var style = new Style(); // this used to work in 20.04 but causes corruption starting with 20.06
          pivotTable.Format( cell.Row, cell.Column, style );
        }
    }
  }
}

I would appreciate if you could investigate this regression!

Thank you in advance for your help.

Kindest,
Michal

@msimon,

I am able to reproduce the issue as you mentioned by using your sample. I found by setting default Style on a cell (PivotFieldType.Row) in pivot table corrupts the file.

We need to evaluate your issue in details. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-54492

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi : thanks for your quick replay, regarding the Paid Support, I believe we have the Site OEM, if this qualifies, could you please advice how to proceed (what info do I need to provide)?

P. S. I will be on PTO next week, hence I will get back to you only afterwards.

@msimon ,

Please note, Site OEM license for Aspose.Cells exists with and without paid support. Please check if you have purchased the license with free support or paid support. If you have purchased the license with paid support, you may escalate this issue by signing in and posting a thread at paid support helpdesk.

Great, please enjoy your holidays. Please follow up when you get back to work.

@msimon
We have fixed this issue.
But for the issue Data formatting problem in the first column cells in the pivot table
We have to roll back the change. If you input same data and datetime values in MS Excel, then refresh the PivotTable, the value of B3:F3 are numberic, not DateTime. So we will work as MS Excel.

@amjad.sahi : thanks for the feedback on the licensing topic, I just checked and we don’t have paid support

@simon.zhao : thank you very much for looking into it, is there a way for me to test your bugfix? are there any plans to include it in a release?

@msimon
The fix will be included in our upcoming release (Aspose.Cells v23.11) that we plan to release in the first half of November 2023. You will be notified when the next version is released.

1 Like

The issues you have found earlier (filed as CELLSNET-54492) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi