The pivot loses header's order after working with input file. Attached screenshot with issue, input file and file with break.
Aspose.Cells version is 8.6.0.7
See code below:
C#
var workbook = new Workbook(@"C:\WrongPivotHeaderOrder.xlsx");
#region Data Block 0
var data0 = new object[,] { { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 2) }, { new DateTime(2015, 1, 2) }, { new DateTime(2015, 1, 5) } };
#endregion
var worksheet0 = workbook.Worksheets[0];
worksheet0.Cells.ImportTwoDimensionArray(data0, 1, 0);
#region Data Block 1
var data1 = new object[,] { { "NameC" }, { "NameD" }, { "NameB" }, { "NameA" }, { "NameA" }, { "NameA" } };
#endregion
worksheet0.Cells.ImportTwoDimensionArray(data1, 1, 1);
#region Data Block 2
var data2 = new object[,] { { 100 }, { 200 }, { 300 }, { 100 }, { 150 }, { 350 } };
#endregion
worksheet0.Cells.ImportTwoDimensionArray(data2, 1, 2);
workbook.CalculateFormula();
var listobject0 = worksheet0.ListObjects[0];
listobject0.AutoFilter.Sorter.Sort();
var pivottable0 = worksheet0.PivotTables[0];
pivottable0.RefreshData();
pivottable0.CalculateData();
workbook.CalculateFormula();
workbook.Save(@"C:\result.xlsx");var workbook = new Workbook(@"C:\WrongPivotHeaderOrder.xlsx");
#region Data Block 0
var data0 = new object[,] { { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 1) }, { new DateTime(2015, 1, 2) }, { new DateTime(2015, 1, 2) }, { new DateTime(2015, 1, 5) } };
#endregion
var worksheet0 = workbook.Worksheets[0];
worksheet0.Cells.ImportTwoDimensionArray(data0, 1, 0);
#region Data Block 1
var data1 = new object[,] { { "NameC" }, { "NameD" }, { "NameB" }, { "NameA" }, { "NameA" }, { "NameA" } };
#endregion
worksheet0.Cells.ImportTwoDimensionArray(data1, 1, 1);
#region Data Block 2
var data2 = new object[,] { { 100 }, { 200 }, { 300 }, { 100 }, { 150 }, { 350 } };
#endregion
worksheet0.Cells.ImportTwoDimensionArray(data2, 1, 2);
workbook.CalculateFormula();
var listobject0 = worksheet0.ListObjects[0];
listobject0.AutoFilter.Sorter.Sort();
var pivottable0 = worksheet0.PivotTables[0];
pivottable0.RefreshData();
pivottable0.CalculateData();
workbook.CalculateFormula();
workbook.Save(@"C:\result.xlsx");