Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Pivot Table - Get data in Pivot Field
Hi -
Basic question: How can I iterate through the items in a Pivot Table report filter? So lets say a pivot table contains a "Car Model" report filter with elements such as "Chevy", "Olds", "Toyota", etc. For starters I just want to be iterate through the Car Model filter and show each element in a MessageBox (just to get the hang of it). Other notes: I'm automating Excel 2007 via C# and VSTO. The PivotTable data source is an OLAP cube stored on a server While I'd like a C# snippet I'll take VB.Net (and even VBA, but third choice) What I really want to do is change the selected element to "Chevy", print the page, select "Olds", print the page, select "Toyota", print the page .... My code so far: Excel.PivotTable pvt = (Excel.PivotTable)Globals.Sheet1.PivotTables("Pivo tTable1"); Excel.PivotField fld = (Excel.PivotField) pvt.PivotFields("[Contract Info].[Model].[Model]"); fld.CurrentPageName = "[Contract Info].[Model].&[Chevy]"; //<- Changes the filter from "All" to "Chevy" // Code works to this point But I can't figure out how to expose the values in the PivotField (psudo code along the lines of:) foreach (PivotItem item in fld.PivotItems) MessageBox.Show(item.Name) Thanks for any suggestions Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pivot table field data | Excel Discussion (Misc queries) | |||
Sorting Page Area Field Data in Excel 2007 Pivot Table | Excel Discussion (Misc queries) | |||
Pivot Table Data field | Excel Programming | |||
Excel Pivot Table Appends a '2' to the field data items | Excel Discussion (Misc queries) | |||
Update Data Field in Pivot Table with Dynamic Excel Range | Excel Programming |