This is the issue I reported earlier, but now I have a standalone sample to reproduce the issue.
Hi Dmitry,
- CELLSNET-43473: Report filter selection changes for the Pivot Table in worksheet “Electronic” after filling in the data source and refreshing the Pivot Table. Report filter selections are changed from “Is UST = False” & “Execution Type = Voice” to “Is UST = True” & “Execution Type = Electronic”.
- CELLSNET-43474: Same Pivot Table as discussed above does not refresh while rendering the results in HTML format.
- CELLSNET-43475: Pivot Table in worksheet “Voice” shown in HTML has different data view as compared to the spreadsheet. However, the report filter selection remains intact, that is; “Execution Type = Voice” & “Is UST = True”.
Btw can I ask the devs to review the script as it reflects the implementation of our reporting engine:
Hi Dimtry
dzmitry.martynau:
1. All refreshes we do at the end to properly render a generic template, any excess or missing refresh/calculate methods they might notice
You are refreshing the Pivot Tables correctly, however, the Workbook.CalculateFormula has to be called once after importing the data. Calling this method second time will not make any difference unless you have changed the cell data on which formula fields are dependent. Anyway, I have evaluated the performance concerns after commenting out the second Workbook.CalculateFormula call without observing any considerable difference in the execution time for the given data.
dzmitry.martynau:
2. Performance recommendations. We use ImportTwoDimensionArray in order to push data in a table, and copy ranges to copy cell formatting, and we do it in blocks by columns, so we can skip columns with formulas. We noticed that as the table grows every iteration takes longer almost in linear progression.
In your given code, you are calling the Cells.ImportTwoDimensionArray method for 184 times. If you could change your application structure to use Cells.ImportDataTable, the performance would be better for large data sets. You may split the DataTable into pieces so that formula columns are not overwritten but the consecutive data should remain in single DataTable in order to reduce the number of Cells.ImportDataTable calls. I will further test this scenario by converting your source to use DataTables, and will keep you posted with updates in this regard. You may also try the approach on your side for testing purpose and let us know of your feedback.
We have also logged your concerns to one of the tickets for product team's review. As soon as we receive any updates, we will let you know here.
Thanks, Babar.
Hi,
Thanks for using Aspose.Cells.
Please download and try the latest fix: Aspose.Cells
for .NET v8.4.0.3 for these issue and let us know your feedback.
About CELLSNET-43473,CELLSNET-43474 and CELLSNET-43475, there are some tips for you:
1. If you change the data source of PivotTable, the PivotItems of PivotField will be changed too.So if you want to use the same filtering conditions, you need set it again.
Because the index of PivotItem will be changed too.
2.If you want to verify it, you can read the “excepted.xlsx” file, you will discover that the CurrentPageItem of PivotField in PivotTable.PageFields is changed.
Please use the codes as follows to print it:
PivotFieldCollection pages = workbook.Worksheets[0].PivotTables[0].PageFields;
Console.WriteLine(pages[0].CurrentPageItem + " " + pages[1].CurrentPageItem);
pages = workbook.Worksheets[1].PivotTables[0].PageFields;
Console.WriteLine(pages[0].CurrentPageItem + " " + pages[1].CurrentPageItem);
3. Changing the codes as follows:
var pivottable0 = worksheet2.PivotTables[0];
pivottable0.RefreshData();
pivottable0.CalculateData();
var worksheet3 = workbook.Worksheets[1];
var pivottable1 = worksheet3.PivotTables[0];
pivottable1.RefreshData();
pivottable1.CalculateData();
To:
var pivottable0 = worksheet2.PivotTables[0];
pivottable0.RefreshData();
int pageCount = pivottable0.PageFields.Count;
PivotField tempField = null;
for (int i = 0; i < pageCount; i++)
{
tempField = pivottable0.PageFields[i];
for (int j = 0; j < tempField.ItemCount; j++)
{
if (tempField.Name.Equals("Execution Type") && (string)tempField.PivotItems[j].Value == "Electronic")
{
tempField.CurrentPageItem = (short)j;
break;
}
if (tempField.Name.Equals("Is UST") && (bool)tempField.PivotItems[j].Value == true)
{
tempField.CurrentPageItem = (short)j;
break;
}
}
}
pivottable0.CalculateData();
var worksheet3 = workbook.Worksheets[1];
var pivottable1 = worksheet3.PivotTables[0];
pivottable1.RefreshData();
pageCount = pivottable1.PageFields.Count;
for (int i = 0; i < pageCount; i++)
{
tempField = pivottable1.PageFields[i];
for (int j = 0; j < tempField.ItemCount; j++)
{
if (tempField.Name.Equals("Execution Type") && (string)tempField.PivotItems[j].Value == "Voice")
{
tempField.CurrentPageItem = (short)j;
break;
}
if (tempField.Name.Equals("Is UST") && (bool)tempField.PivotItems[j].Value == true)
{
tempField.CurrentPageItem = (short)j;
break;
}
}
}
pivottable1.CalculateData();Thanks, Shakeel. This version fixed my issue. I will test it against other similar scenarios.
dzmitry.martynau:
Thanks, Shakeel. This version fixed my issue. I will test it against other similar scenarios.
dzmitry.martynau:
One more question. Since I want to preserve original page field values, I need to support the case when data don't contain the page field value I want to preserve. In this case PivotItems doesn't contain the value I need to restore. What can I do in this case, is there a way to insert a corresponding PivotItem via API?
The issues you have found earlier (filed as CELLSNET-43475;CELLSNET-43474;CELLSNET-43473) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.