Free Support Forum - aspose.com

PivotTable and filter --> Excel Crashes

Hi,

I can’t set a filter in my pivotTable?!
I tested with a created pivotTable with aspose, and with an existing PivotTable, where I just added a filter.

The index Column 0 is a column with autoID

I tested this codes:


Dim index2 As Integer = myPivot.PivotFilters.Add(0, Pivot.PivotFilterType.CaptionEqual)
Dim Filter As Pivot.PivotFilter = myPivot.PivotFilters(index2)
Filter.Value1 = “4169”
Filter.AutoFilter.Filter(0, “4169”) 'I tested without it
Filter.AutoFilter.Refresh() 'I tested without it
myPivot.RefreshData() 'I tested without it
myPivot.CalculateData() 'I tested without it
–> no filter set

Dim index As Integer = myPivot.PivotFilters.Add(0, Pivot.PivotFilterType.CaptionEqual)
Dim Filter As Pivot.PivotFilter = myPivot.PivotFilters(index)
Filter.Value1 = “4169”
Filter.AutoFilter.Custom(0, FilterOperatorType.Equal, “4169”)
Filter.AutoFilter.Refresh() 'I tested without it
myPivot.RefreshData() 'I tested without it
myPivot.CalculateData() 'I tested without it
–> no filter set

When I declare the new filter, in my mind I thought that it was better with “ValueEqual” instead “CaptionEqual”

Dim index2 As Integer = myPivot.PivotFilters.Add(0, Pivot.PivotFilterType.ValueEqual)
Dim Filter As Pivot.PivotFilter = myPivot.PivotFilters(index2)
Filter.Value1 = “4169”
Filter.AutoFilter.Refresh() 'I tested without it
myPivot.RefreshData() 'I tested without it
myPivot.CalculateData() 'I tested without it

–> with ValueEqual, my Excel crashes when I open the file :
"We found a problem with some content in xxx.xlsx. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click yes

I click yes, and then this message whows:
Removed Feature: PivotTable report from /xxxxxx1.xml part (PivotTable view)

error043040_01.xml

Des erreurs ont été détectées dans le fichier « C:\Users\e01641\AppData\Local\Temp\OSRC-61.xlsx »Fonction supprimée: Rapport de tableau croisé dynamique dans la partie /xl/pivotTables/pivotTable11.xml (Mode Tableau croisé dynamique)

My Excel is:
Excel for Office 365 MSO (16.0.11328.20418) 32 bits

here is my code to download the file:
monExcel.Save(Me.Response, “OSRC.xlsx”, Aspose.Cells.ContentDisposition.Attachment, New Aspose.Cells.XlsSaveOptions(SaveFormat.Xlsx))

@fredlang,
Thank you for your query. Please share your source Excel file, program output file and an expected output file created with MS Excel along with the runnable console application with us for our testing. We will reproduce the problem and provide our feedback after analysis.

Hi,

Thanks for your reply.

I cant give you my real project becauseof confidentiality.

I created a sample project.

The first sheet contains data. The second sheet contains pivottable.

I want to filter in the region column (like the screenshot_1.png)
Region=Central for example

I tested with a lot of code, but no one works. Can you give me the code to filter the region?

If not possible, I can create the filter manually, but I would have to change the filter value in code.

I dont put the licence file, and I dont put the dll because it s too big. (I tested with the latest version)

In the zip I save in SaveFormat.Excel97To2003 but I tested (and I want this format) SaveFormat.Xlsx

Thanks a lot
test pivottable excel aspose.zip (6.5 MB)

@fredlang,
We are analysing this information and will share our feedback soon.

@fredlang,
We are working over your requirement but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as
CELLSNET-47037 – Adding filter to PivotTable