ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help! Turning off PivotTable Subtotals (https://www.excelbanter.com/excel-programming/273072-help-turning-off-pivottable-subtotals.html)

Jim[_17_]

Help! Turning off PivotTable Subtotals
 
Hello,

I'm trying to turn off Excel 2002 PivotTable Subtotals
using C#.NET. I'm able to set other field properties, but
I cannot figure out how to use the set_Subtotals method or
locate that .Subtotals property that so many Excel 97
programming examples use. Sample of my attached code
below. Any help would be greatly appreciated.

Thanks,
Jim

Excel._Workbook oWB;
Excel._Worksheet
oSheet;
Excel.PivotCache
pivotCache;
Excel.PivotTable
pivotTable;
Excel.PivotField
pivotField;
string
sourceData;
Excel.Range
oRng;

oWB = mXL.Workbook;
oSheet = (Excel.Worksheet)
oWB.Sheets.Add(Type.Missing, Type.Missing, Type.Missing,
Type.Missing);
oRng = oSheet.get_Range
("A7","A7").Cells;

Excel.PivotCaches pivotCaches =
oWB.PivotCaches();
sourceData = "Data!R1C1:R" +
mLastRow + "C" + mLastCol;
pivotCache = pivotCaches.Add
(Excel.XlPivotTableSourceType.xlDatabase, sourceData);

pivotTable =
pivotCache.CreatePivotTable(oRng, "Flow-Through",
Type.Missing,
Excel.XlPivotTableVersionList.xlPivotTableVersionC urrent);

pivotTable.SmallGrid = false;

// Pivot Table Page Area
pivotField = (Excel.PivotField)
pivotTable.PivotFields("Region");
pivotField.Orientation =
Excel.XlPivotFieldOrientation.xlPageField;
pivotField.Position = 1;

pivotField = (Excel.PivotField)
pivotTable.PivotFields("Opportunity Owner");
pivotField.Orientation =
Excel.XlPivotFieldOrientation.xlPageField;
pivotField.Position = 1;

// Pivot Table Row Area
pivotField = (Excel.PivotField)
pivotTable.PivotFields("Account Name");
pivotField.Orientation =
Excel.XlPivotFieldOrientation.xlRowField;
pivotField.Position = 1;



All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com