ClosedXML / ClosedXML/ClosedXML
Rows for making Pivot table
- Dominant language
- C#
- Stars
- 5.7k
- Forks
- 933
- Avg merge
- 12h 14m
- Merged PRs (30d)
- 1
Description
**Do you want to request a *feature* or report a *bug*?**
- [x] Bug
- [ ] Feature
**Version of ClosedXML**
e.g. 0.87.1
**What is the current behavior?**
**If the current behavior is a bug, please provide the steps to reproduce and
if possible a minimal demo of the problem with a sample spreadsheet.**
**What is the expected behavior or new feature?**
**Did this work in previous versions of our tool? Which versions?**
- [x] I attached a sample spreadsheet. (You can drag files on to this issue)
**
[BigCell.xlsx](https://github.com/ClosedXML/ClosedXML/files/1141926/BigCell.xlsx)
:**
```c#
// Code im making pivot
// If i use all rows for making pivot (from XL attached) - saved file will be corrupted and have not a pivot table
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("Сальдо в рублях");
// But when ii use only 536 rows for making pivot (from XL attached) - its will be all ok
IXLPivotTable pt;
var source = ws.Range(3, 1,**536**, 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("Сальдо в рублях");
```
I have some identical tables, which have same columns with different data. Some XL files works fine after makin pivot, but one - not. After few hours i found difference in "big" rows (example I537 to I600). When i limit rows in range for pivot table to 536 - it works well. I dont have a problem to delete them (i dont use in my work), but may be it will helps make your library better in future version.
Contributor guide
Research direction
Reproduce the failure with BigCell.xlsx using the code around IXLPivotTable and PivotTables.AddNew, comparing the full source range with the 536-row range. Inspect the pivot-table generation path and confirm that the full range produces a valid saved workbook containing the pivot table without corrupting the file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100