ClosedXML / ClosedXML.Report

ClosedXML.Report is a tool for report generation with which you can easily export any data from your .NET classes to Excel using a XLSX-template.
https://closedxml.github.io/ClosedXML.Report/
MIT License
514 stars 108 forks source link

Template row/column sizes not respected #309

Open The-MAZZTer opened 1 year ago

The-MAZZTer commented 1 year ago

I should be able to specify row/column sizes in my template and not have them overridden.

In Excel if I go to View > Page Layout I can see if my spreadsheet fits on a page.

ClosedXML.Report seems to size columns/rows to fit which means a spreadsheet which should fit on 1 page is overflowing both horizontally and vertically over the page boundary. This is not acceptable in hard copy scenarios.

The-MAZZTer commented 1 year ago

As an addendum. I understand the use case of autosizing rows/columns. Furthermore on complex templates I can see situations where a row/column would need to be set to two conflicting sizes if size preservation was desired (for example, staggering tables in weird layouts that push each other right and down). However size preservation would be useful in the scenario I presented above. For size conflicts I say it is up to the developer to make column/row sizes consistent in such scenarios in their template.

The-MAZZTer commented 1 year ago

After some further inspection, I suspect ClosedXML is not reading the column sizes correctly from the template document. The IXLColumn object has values for Width in some cases that do not match the values Excel uses for the same document.

However rows in a vertical table, including the first one, do not match the height of the template row even when this glitch is removed from consideration.