Selecting a pivot table filter

How can I programmatically select a specific item from a pivot table filter?

Hi,

Please try this sample code to set the current page item index in the pivot table :

wb.Worksheets[0].PivotTables[0].PageFields[0].CurrentPageItem = index;

also, try this code to hide the specific field item :

wb.Worksheets[0].PivotTables[0].PageFields[0].HideItem(index, true);

thanks.

Philip,

Thank you for your code example.

I followed it, but when I save the file, Excel does not save the pivot table with the new index:

Workbook wb = new Workbook(“C:\Reports\DIST Bus Unit A Tables June YTD 2011_R1.xlsx”, loadOptions);

Worksheet ws = wb.Worksheets[“Opened Inquiries”];

ws.PivotTables[0].PageFields[1].CurrentPageItem = 2;

wb.Save(“C:\Reports\DIST Bus Unit A Tables June YTD 2011_R3.xlsx”);


The drop down is essentially unchanged.

Jeff




Hi,

Please set the refreshdataonopeningfile flag to true :

wb.Worksheets[0].PivotTables[0].RefreshDataOnOpeningFile = true;

If this issue is still there , please kindly provide us source and output xlsx files ,We will look into it and update you asap.

thanks.