eplus操作excle行高自动换行
1 private static void ChangeAllRowHeight(string filePath, string sheetName, double rowHeight) 2 { 3 using (ExcelPackage excelPackage = new ExcelPackage(new FileInfo(filePath))) 4 { 5 ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets[sheetName]; 6 int rowCount = excelWorksheet.Dimension.End.Row; 7 8 // Set row height for each row and disable wrap text 9 for (int i = 1; i <= rowCount; i++) 10 { 11 excelWorksheet.Row(i).Height = rowHeight; 12 excelWorksheet.Row(i).Style.WrapText = false; // Disable wrap text 13 14 // Set background color for the first row 15 if (i == 1) 16 { 17 excelWorksheet.Row(i).Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; 18 excelWorksheet.Row(i).Style.Fill.BackgroundColor.SetColor(Color.Gray); // Set gray background 19 } 20 } 21 22 excelPackage.Save(); 23 } 24 }
本文来自博客园,作者:吖吼、,转载请注明原文链接:https://www.cnblogs.com/YaHouSir/articles/18295655

浙公网安备 33010602011771号