Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
All of the following lines work to set defaults for the sheet except for DefaultRowHeight. It doesn't see to do a thing. I can set the row height for individual rows just fine, but the default does nothing. Any ideas?

VB
Dim wks As ExcelWorksheet 
...
...
...
wks.Cells.Style.Font.Name = "Calibri"
wks.Cells.Style.Font.Size = 10
wks.Cells.Style.Font.Color.SetColor(Color.Black)
wks.Cells.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center
wks.Cells.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center
wks.Cells.Style.Numberformat.Format = "@"
wks.DefaultRowHeight = 15


What I have tried:

Setting DefaultRowHeight. It doesn't work.
Posted
Updated 25-Jun-18 23:13pm
Comments
avianrand 24-Jun-18 21:34pm    
Why does this forum change my subject to mostly lower case? That doesn't make sense. It should read "EPPlus DefaultRowHeight doesn't work" but it changed it on its own. Ugh.
Peter_in_2780 24-Jun-18 22:47pm    
A stab in the dark. DefaultRowHeight may apply to subsequently created sheets, rather than altering existing ones.
avianrand 26-Jun-18 8:28am    
That's a good stab. I thought of that as well. But it's a sheet property, so the sheet has to exist first before using it. And my code creates several dozen sheets after the first time I set that and they all have the default Excel 12.75 height.

1 solution

Seems, a value of 15 is the default row height for EPPlus. So, your code changes nothing.
EPPlus/ExcelWorksheet.cs at master · pruiz/EPPlus · GitHub[^]

I'd strongly suggest to change a RowHeight (instead of DefaultRowHeight) for specific range:
wks.Range["A1:D100"].RowHeight = 15


See: How To Apply Cell Text Alignment, Row Height, Column Width in An Excel Sheet (C# EPPlus) - Part Four[^]

[EDIT]
Quote:
You've linked to a forked version which was last updated in 2012. The official repository is:
https://github.com/JanKallman/EPPlus[^] (Last updated 27 days ago.)

Thank you, Richard!
 
Share this answer
 
v2
Comments
avianrand 26-Jun-18 7:17am    
Before I posted my question I tried setting DefaultRowHeight to other values like 25, 40, etc. None of them had an effect.
Richard Deeming 26-Jun-18 10:11am    
You've linked to a forked version which was last updated in 2012. The official repository is:
https://github.com/JanKallman/EPPlus[^] (Last updated 27 days ago.)
Maciej Los 26-Jun-18 13:40pm    
Good to know. Thank you, Richard.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900