[]
Generate the corresponding function "GETPIVOTDATA" for the cells in the pivot table.
string GenerateGetPivotDataFunction(IRange destination = null)
Function GenerateGetPivotDataFunction(Optional destination As IRange = Nothing) As String
| Type | Name | Description |
|---|---|---|
| IRange | destination | Indicates for which area the "GETPIVOTDATA" function is generated. |
| Type | Description |
|---|---|
| string | "GETPIVOTDATA" function |
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"]);