Using latest Closed XML (0.76) on Net 4.5.1
Created a Worksheet with a table by:
DataTable Table = ...
var DataWorkSheet = Workbook.Worksheets.Any(x => x.Name == "Data") ?
Workbook
.Worksheets
.First(x => x.Name == "Data") :
Workbook
.Worksheets
.Add("Data");
int Start = ... // calculate cell start
var Source = DataWorkSheet
.Cell(Start, 1)
.InsertTable(Table, Name, true);
var Range = Source.DataRange;
This is done inside a loop (i.e. multiple tables in the "Data" sheet). A problem arises where the generated Excel document can't be opened if multiple pivot tables are created in a separate sheet.
var PivotWorkSheet = Workbook
.Worksheets
.Add(Name);
var Pivot = PivotWorkSheet
.PivotTables
.AddNew(Name, PivotWorkSheet.Cell(1, 1), DataRange);
Any ideas why and how to debug?
It is a . NET-library for report generation Microsoft Excel without requiring Excel to be installed on the machine that's running the code. With ClosedXML.
ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (. xlsx, . xlsm) files.
ClosedXML is an open source library created based on OpenXmlSdk. It's more user friendly. ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (.
This is the same issue as in ClosedXML - Creating multiple pivot tables.
For the record, it's caused by ClosedXML
bug which requires source code modification as in my answer of the linked question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With