We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Preselecting pivot filter (autofilter) values

Hello,

I’ve looked at the various examples for adding pivot filters to fields used in a pivot table. Maybe I am missing something but it seems that I can only add “caption/label” filters or “value” filters.

I’d like to add a filter with the ability to preselect some of the autofilter values. See Attached screen shot of what I mean. My need for this is so our users can edit the filter after they receive the report. Can you point me to some documentation or sample code?

Hi,


Thanks for your screen shot.

I observed your requirements a bit. Could you attach a template file with your desired filters set for the pivot table, we will check and look into it soon.

Thank you.

Thanks for looking… Attached is a template file with an example filter on the field named DTE Year.

Hi,


Well, I think you are right, PivotFilterCollection.Add() overloads do not provide enough variety of options to support your needs. If in case of simple Auto-filters, we have multiple methods under AutoFilter object, but not for PivotTable’s filter case. I observed your requirement as per your sample Pivot table in the sample file you attached in the previous post. We will check if we can share the sample code for your needs if it is supported. If the feature is not available, we will try to support it to enhance the PivotTable feature. I have logged a ticket with an id “CELLSNET-41913” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,


We have evaluated your requirements further. I think you may try to use HideItem() API for your needs, see the sample code segment:

//Hide the first DTE Year item/value
workbook.Worksheets[1].PivotTables[0].ColumnFields[1].HideItem(0, true);
//Similarly you may hide your unwanted items to filter your desired data.


Thank you.

That did it and fits our needs perfectly. Many thanks!

Hi,


Good to know that it sorts out your issue.

Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.