New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IXLRows.AdjustToContents() ignores text wrapping #934
Comments
Complete the full issue template. |
Did this work in previous versions of our tool? Which versions? |
Also, I can't run your code sample. Read the instructions in the issue template again. I'll reopen the issue when you've completed it fully. |
I've changed the demo code. |
Still can't run it. |
See this part? |
So I've attached a xlsx file. |
You should be calling sheet.Column(1).AdjustToContents(); |
Ehm, adjusting row heights and column widths are completely different operations, aren't they? |
I think sheet.Column(1).AdjustToContents() is wrong because my row's width is a fixed value like 10 or 5. |
Ok, I didn't read properly. That's what happens when people submit incomplete issue templates. Yes, you're right. Text wrapping is not currently taken into account when calculating a row's height. |
@weskerjiang Sorry for being rude earlier. |
Never mind!^_^ |
Sorry, any progress? I have this issue too. Any plans to fix this? |
I've found that it works in current 0.94 Dev version, when you call ws.Row(1).AdjustToContents(); followed by ws.Row(1).ClearHeight(); . Without calling ClearHight(), inside xlsx is the file /xl/worksheets/sheet1.xml with an attribute customHeight="1" and the row height is not adjusted in Excel.
When I call ClearHeight(), this attribute is removed and row height is displayed in Excel correctly (the Row(1).Height is still wrong, so I can't test it with Assert() function). To sum up, it will help to call ClearHeight() as a part of the AdjustToContents() function.
|
In fact, you don't even need |
So, why there is a |
AFAIK,
|
OK, but even when I call row(1).AdjustToContents(), I expect that the attribute ClearHeight() should set height to the default worksheet row height value (not null), what it IMHO does. |
Setting any particular value will disable the automatic change of row height. See #352, for example |
I just wanted to highlight that calling AdjustToContents() followed by ClearHight() does what is expected, and it's the same result as AutoFit Row Height in Excel. Without ClearHight(), resulting XML is different (attribute customHeight="1" is present). |
Hi, static void Main()
{
var wb = new XLWorkbook();
var ws = wb.AddWorksheet("Sheet1");
ws.Row(1).Style.Alignment.WrapText = true;
ws.Cell(1,1).Value= "Testing merged columns row auto height with the closed xml; ssgsgsgdgdfgdfgdgdfgdgdfgdfgjknuidghniupghispgjnsipjgkndjksipzsjfniudhfubnsifjbifjsfhbhidjfbiusgyaitrfbfgsyfgsyfgsyfgsdyfgsfysfgfsf skdjfhsduifhdsuifshdufihsdfuihsuifhsduifhsduifhsuifhsuifhsdifhsduifhsdifhsfisbdfiusfisdhfsduifhsduifhsuifsdfyuhfsdfbuishdfisudhgsdiuhsuighsdiugsbugsbgiusghsisugihsuighsufhsdighusighsuighsuighsuighshg";
ws.Range("A1:E1").Merge();
ws.Row(1).AdjustToContents();
ws.Row(1).ClearHeight();
wb.SaveAs("Test1.xlsx");
} |
Again,
Automatically expand the row height to include the contents is Excel's responsibility. And Excel ignores the contents of the merged cells, whether it's about row height or about column width. This is by design. You can try it yourself by double-clicking on row delimiters in Excel - it treats merged cells as if they were empty. |
yeah.. I see its Excel problem by design, it can be fixed in by custom code. Thanks for your time. |
@MSAppsDev I'm facing the same issue,
Can you please guide me, how you have fixed this issue? |
Hello. I faced the same problem and cannot solve it. Have you solved it somehow? If yes then could you explain how? Thank you. |
I got it using |
I can't believe it's still doesn't work =\ i don't have any merged cells, but |
Any progress with this issue? |
This answer, posted above, just worked for me. Not very intuitive, but it does work |
Sorry, worked for me too.. If open file with Excel)) So it's Libreoffice bug) |
Read and complete the full issue template
Do you want to request a feature or report a bug?
Version of ClosedXML
0.93
What is the current behavior?
The IXLWorkSheet.Rows().AdjustToContens() does not work.
What is the expected behavior or new feature?
I want the row's height can change when the cell's content is too long.
Did this work in previous versions of our tool? Which versions?
No! It does not work in 0.92.1
Reproducibility
Code to reproduce problem:
demo2.xlsx
The text was updated successfully, but these errors were encountered: