Microsoft, Excel, PivotTable, C#, VBA
Posted on 2007-08-05
PivotTable Column Headers' cells
I'm trying to solve a problem where I create a pivotTable with a few columns and need to adjust the size of the cells those column headers go to. Issue is I am not able to reach individual cells of these column headers while I'm creating the column headers as a data field.
I add a data field to pivotTable like this: //code is C#, interop with MS Excel classes
for(int i=0, i<3, i++)
PivotField pivotField = (pivotField) pivotTable.AddDataField(pivotTable.CubeFields[pivotFieldName], caption, Missing.Value]
/*now I want to access that particular cell that the header (caption) was added to, and..
pivotField.DataRange gives the pivotField cell and not the column header cell
pivotField.ColumnWidth doesn;t exist
pivotField.Cells doesn;t exist
pivotField.CubeField gives CubeField's data and not Excel's cell/range
Essentially, what I need is to reach column header cells through pivotField cell that I have
Any solutions in VB or C# are greatly appreciated.