diff --git a/Tiobon.Core.Common/Helper/NPOIHelper.cs b/Tiobon.Core.Common/Helper/NPOIHelper.cs index 71641da7..3198ea43 100644 --- a/Tiobon.Core.Common/Helper/NPOIHelper.cs +++ b/Tiobon.Core.Common/Helper/NPOIHelper.cs @@ -308,7 +308,6 @@ public class NPOIHelper try { sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256 - } catch (Exception e) { @@ -316,6 +315,18 @@ public class NPOIHelper } } + for (int rowNum = 2; rowNum <= sheet.LastRowNum; rowNum++) + { + IRow currentRow = sheet.GetRow(rowNum); + + int length = 25; + foreach (var item in currentRow.Cells) + { + if (item != null) + length = Encoding.UTF8.GetBytes(item.ToString()).Length > length ? Encoding.UTF8.GetBytes(item.ToString()).Length : length; + } + currentRow.HeightInPoints = 35 * (length / 150 + 1); + } using (MemoryStream ms = new MemoryStream()) { workbook.Write(ms);