Hi-
I want to copy the values from the last 2 columns of a pivot table (The Grand totals) to a new tab. Values ONLY.
Thanks
-Tom
Workbook workbook = new Workbook();
workbook.LoadFromFile(path+ "PivotTableExample.xlsx");
Worksheet sheet = workbook.Worksheets["PivotTable"];
Worksheet newSheet = workbook.Worksheets.Add("New Sheet");
XlsPivotTable pt = (XlsPivotTable)sheet.PivotTables[0];
CellRange cr = pt.Location;
int firstRow = cr.Row;
int lastRow = cr.LastRow;
int lastColumn = cr.LastColumn;
CellRange cellRange = sheet.Range[firstRow,lastColumn-1,lastRow,lastColumn];
sheet.Copy(cellRange, newSheet, 1, 1, true, true);
workbook.SaveToFile(path+"result.xlsx",ExcelVersion.Version2016);
workbook.Dispose();