ClosedXML / ClosedXML/ClosedXML
Render pivot table values
- Dominant language
- C#
- Stars
- 5.7k
- Forks
- 933
- Avg merge
- 12h 14m
- Merged PRs (30d)
- 1
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?
Contributor guide
Research direction
Start at PivotTables.AddNew and the save path, reproducing the example with wsPT.RowsUsed() and wsPT.Cell(1,2) before and after opening the file in Excel. Done means the generated workbook exposes the pivot results through the worksheet API without requiring Excel to open and resave it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100