Hi, I'm using XLSIO 12.2.0
Largely the code following "Following code example illustrates how to create a pivot table with existing data in the worksheet, using XlsIO."
The workbook that is created contains the data on the first sheet, the entire data is correctly assigned to the named range
A second sheet ("Pivot") is created, however this is empty ... other than a range A1:B3 seems to exist which contains no data, formatting, names, ...
Here's my code:
Stepping through I can see that
pivotCache contains the correct number of rows and columns
pivotTable contains the correctly named fields from the raw data
Dim rawDataSheet As IWorksheet = pivotBook.Worksheets(0)
rawDataSheet.ImportDataTable(myDataTable, True, 1, 1)
pivotBook.Names.Add("PivotRawDataRange").RefersToRange = rawDataSheet.Range(1, 1, myDataTable.Rows.Count + 1, myDataTable.Columns.Count)
Dim pivotSheet As IWorksheet = pivotBook.Worksheets.Create("Pivot")
pivotSheet.Activate()
Dim pivotCache As IPivotCache = pivotBook.PivotCaches.Add(pivotBook.Names("PivotRawDataRange").RefersToRange)
Dim pivotTable As IPivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet("A1"), pivotCache)
pivotTable.Fields(5).Axis = PivotAxisTypes.Page
pivotTable.Fields(1).Axis = PivotAxisTypes.Row
pivotTable.Fields(10).Axis = PivotAxisTypes.Column
Dim field As IPivotField = pivotSheet.PivotTables(0).Fields(19)
pivotTable.DataFields.Add(field, "Sum", PivotSubtotalTypes.Sum)
pivotSheet.Activate()
pivotBook.SaveAs("QuantaExtractKPI.xlsx", Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2010)
pivotBook.Close()
qExcelEngine.Dispose()
Any help much appreciated
thanks scott