Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Created Unassigned: Excessive Memory allocation using Borders [8862]

$
0
0
Hi, I am creating a relatively simple spreadsheet (from a dataset/datatable) with 27 columns and around 2500 rows and while performance is much better than Excel Interop, using borders can cause memory use to climb dramatically.

The company requires a thin border around the header and whole table and a hair border between columns and rows.

If I define borders on this table my application memory use increases from ~120MB to 400+MB while the inside borders are defined. Filling the table with data on a cell-by-cell basis setting number formats etc caused a ~50MB increase

Larger tables (9000+ rows) can push the memory use over 1.4GB and cause an out-of-memory exception.

Compiling and/or running a 64-bit application is not an option due to the mix of hardware + OS in use.

I have tried the following (where dt is a datatable)
var rngContent = ws.Range(1, 1, dt.Rows.Count, dt.Columns.Count);
rngContent.Style.Borders.InsiderBorder = XLBorderStyleValues.Hair;
rngContent.Style.Borders.OutsideBorder = XLBorderStyleValues.Thin;
or on a row-by-row basis
or on a cell-by-cell basis (OutsideBorder)
and using SetInsideBorder & SetOutsideBorder

Setting other formatting options such as alignment across the table or on a cell by cell basis etc does not appear to increase the memory in this way.

Viewing all articles
Browse latest Browse all 1877

Trending Articles