[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IRange.GenerateGetPivotDataFunction

GenerateGetPivotDataFunction Method

GenerateGetPivotDataFunction(IRange)

Generate the corresponding function "GETPIVOTDATA" for the cells in the pivot table.

Declaration
string GenerateGetPivotDataFunction(IRange destination = null)
Function GenerateGetPivotDataFunction(Optional destination As IRange = Nothing) As String
Parameters
Type Name Description
IRange destination

Indicates for which area the "GETPIVOTDATA" function is generated.

Returns
Type Description
string

"GETPIVOTDATA" function

Examples
worksheet.Range["A1:B3"].Value = new object[,] {{"Region", "Amount"}, {"East", 120}, {"West", 90}};
IPivotCache cache = workbook.PivotCaches.Create(worksheet.Range["A1:B3"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(cache, worksheet.Range["D1"], "SalesPivot");
pivotTable.PivotFields["Region"].Orientation = PivotFieldOrientation.RowField;
pivotTable.AddDataField(pivotTable.PivotFields["Amount"], "Sum of Amount", ConsolidationFunction.Sum);
IRange valueCell = pivotTable.DataBodyRange[0];
string formula = valueCell.GenerateGetPivotDataFunction(worksheet.Range["G1"]);