I created a Pivot Table in Excel using c# and was able to specifi RowFiled, ColumnField and Datafield as:
Xl.PivotField pvtRow1 =((Xl.PivotField)pvt.PivotFields("Description"));
pvtRow1.Orientation = Xl.XlPivotFieldOrientation.xlRowField;
Xl.PivotField pvtCol =((Xl.PivotField)pvt.PivotFields("PortName"));
pvtCol.Orientation = Xl.XlPivotFieldOrientation.xlColumnField ;
Xl.PivotField pvtFld1 =((Xl.PivotField)pvt.PivotFields("DurContrib"));
pvtFld1.Orientation = Xl.XlPivotFieldOrientation.xlDataField;
It is working but my question is: is this the right way of doing it and next
a) how can I take out the automatic subtotal and have the flexibility of showing the rowGrand and ColumnGrand
b) is there anyother way of creating a CalculatedField other than by using AddDataField
c) how can I increase the number of columnfields/rowfields in the pivottable
d) how can I change the positions of the datafields so as to show up as columns rather than in rows Recording a macro gives an idea about the code but C# doesn't have similar functionailities/objects.
e) is there any book which describes how to convert VBA macros to C#
Any help or code snippet will be helpful.
Thanks

HOw to handle this using c#
meet_kuldeep
Hi,
Thanks for posting. You probably have a better chance to get replies if you post your questions at: http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.officedev&lang=en&cr=US where programing with Office PIA topics are mostly discussed.
Thanks,
Jing Lou/SDET Lead