PC Review


Reply
Thread Tools Rate Thread

C# Add-in and PivotTables

 
 
James Igoe
Guest
Posts: n/a
 
      18th Nov 2009
I am working on a C# add-in that modifies pivot tables. I have done this
work in VBA, and the object model seems straightforward, e.g.,
PivotTable-PivotFields-PivotItems, but I can not get the object for
PivotItems, or iterate through the items. Do I need something other than
PivotItems?

Code for PivotFields, that works:

IExcel.PivotFields pvtfs =
(IExcel.PivotFields)pvtTable.get_PageFields(Missing.Value);
foreach (IExcel.PivotField pvtf in pvtfs)
{

Code for the does not work, and PivotItems shows no values (as in count):

IExcel.PivotItems pvtis =
(IExcel.PivotItems)pvtf.PivotItems(Missing.Value);
foreach (IExcel.PivotItem pvti in pvtis)
{



Similarly, even though I can iterate the CubeFields, I can not edit
some parameters, although I can retrieve its value, e.g., trying to
modify EnablemultiplePageitems throws an error:

IExcel.CubeFields cbfs = (IExcel.CubeFields)pvtTable.CubeFields;
foreach (IExcel.CubeField cbf in cbfs)
{
string cbfname = cbf.Name;
bool cbfMultiPage = cbf.EnableMultiplePageItems;

if (cbfname == dimensionName & cbfMultiPage == false)
{

cbf.EnableMultiplePageItems = true;

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivottables marksj Microsoft Access 1 15th Apr 2008 10:09 PM
pivottables lennert Microsoft Excel Discussion 1 17th Feb 2006 01:08 PM
New to Pivottables- need help =?Utf-8?B?Y29hbF9taW5lcg==?= Microsoft Excel Charting 1 6th Jun 2005 06:48 PM
PivotTables/VBA jngi Microsoft Excel Programming 2 24th Sep 2004 12:27 PM
PivotTables =?Utf-8?B?SmFrZXlJRQ==?= Microsoft Excel New Users 2 11th Feb 2004 10:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.