Open
Description
Hi, i, using ClosedXML for creating pivot tables. i need to create multiple pivot tables and then need to compare them. I create pivot tables via PivotTables.AddNew(). All works good - i see pivot tables in my files. But when im try to get values - there is null. Here is my code to create pivot:
IXLPivotTable pt;
var source = ws.Range(3, 1, excelRow - 2, excelColumn).AsTable();
var range = source.DataRange;
var header = ws.Range(3,1, 3, excelColumn);
var dataRange = ws.Range(header.FirstCell(), range.LastCell());
var name = "Сводная по дебиторке";
var wsPT = wb.Worksheets.Add(name);
pt = wsPT.PivotTables.AddNew(name, wsPT.Cell(1, 1), source);
pt.RowLabels.Add("Ответственный");
pt.RowLabels.Add("Филиал отгрузки");
pt.ColumnLabels.Add("Документы");
pt.Values.Add("Сальдо в рублях");
wb.Save();
int excelRow2 = wsPT.RowsUsed().Count();
Here excelRow2 value = 0. Its wrong. When i try to evaluate wsPT.Cell(1,2) its empty, but in my file its not empty. I cant read results of pivot...
When i open XL file in Windows, then just save it throught Excel and restart my code excelRow2 value changed to right and wsPT.Cell(1,2) have right value. May be i am doing something wrong?
May be there is another way to get the values from result pivot table?