I have been successful in opening workbook, then loading pivot table into a variable. I can apply necessary filters to pivot table and i can calculate the table without issues. However how do i read values from the refreshed pivottable?
- Code: Select all
var pt = workbook.Worksheets[warConfig.SheetName].PivotTables["PivotTable1"] as XlsPivotTable;
var camFilter = new PivotReportFilter(warConfig.FilterField , true);
camFilter.IsMultipleSelect = true;
camFilter.FilterItemStrings = new List<string> { warConfig.FilterValue };
var valueTypeFilter = new PivotReportFilter("Value Type", true);
valueTypeFilter.IsMultipleSelect = false;
valueTypeFilter.FilterItemStrings = ["Hrs"];
pt.ReportFilters.Add(camFilter);
pt.ReportFilters.Add(valueTypeFilter);
pt.CalculateData();
I Tried pt.RowFields & pt.DataFields this just returns the model structure no values.