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
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))