EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.8k stars 274 forks source link

Issue with row height adjustment in EPPlus library #906

Closed Altservice closed 8 months ago

Altservice commented 1 year ago

I am encountering an issue with adjusting the row height in EPPlus, a library used for working with Excel files in .NET applications. I am unable to automatically adjust the row height based on the content of merged cells.

Here is the scenario:

I have a worksheet where I merge cells in a row using the Merge property. The merged cells contain text that may wrap and require multiple lines to display fully. I am using the paintCell method to set the cell value, alignment, font size, and text wrapping properties. Problem: While the text within the merged cells correctly wraps, the row height does not adjust to accommodate the wrapped text. As a result, the text becomes hidden behind the cell boundaries.

Attempted Solution: I have attempted to manually adjust the row height using the worksheet.Row(row).Height property and set it to -1, which should automatically adjust the row height based on the cell content. However, this approach did not yield the desired result.

Expected Outcome: I expect the row height to automatically adjust based on the wrapped text within the merged cells. This will ensure that the entire text is visible within the merged cells without being cut off or hidden.

Please provide guidance on how to resolve this issue or any alternative approaches to dynamically adjust the row height in EPPlus when working with merged cells.

Thank you for your assistance.

JanKallman commented 1 year ago

Excel will not autofit rows on cells that are merged with WrapText on load. You will have to set the row height manually yourself. Cells not merged will autofit on load if the cell has WrapText set to true.

OssianEPPlus commented 8 months ago

Closed due to inactivity.