Nopi 导出设置行高

1.导出excel行显示不完整数据客户不满意,需要我们处理

for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
            {
                HSSFRow currentRow = sheet.GetRow(rowNum);
                HSSFCell currentCell = currentRow.GetCell(6);

                HSSFCell currentCell21 = currentRow.GetCell(21);
                int length = Encoding.UTF8.GetBytes(currentCell.ToString()).Length;//获取当前单元格的内容宽度
                int length2 = Encoding.UTF8.GetBytes(currentCell21.ToString()).Length;//获取当前单元格的内容宽度
                if (length2 > length)
                {
                    currentRow.HeightInPoints = 20 * (length2 / 40 + 2); 
                }
                else
                {
                    currentRow.HeightInPoints = 20 * (length / 40 + 2); 
                }
                
                 
            }

 备注:比较索引为6,21 的列,判断设置行高的标准

原文地址:https://www.cnblogs.com/linsu/p/8488208.html