1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | static class EPPlusExtensions { /// <summary> /// 水平 / 垂直 置中 /// </summary> public static void HorizontalVerticalAlignmentCenter(this OfficeOpenXml.Style.ExcelStyle obj) { obj.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; obj.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center; } /// <summary> /// 設定儲存格填滿顏色和格式 /// </summary> public static void SetBackgroundColor(this OfficeOpenXml.Style.ExcelFill obj, System.Drawing.Color color,OfficeOpenXml.Style.ExcelFillStyle excelFillStyle = OfficeOpenXml.Style.ExcelFillStyle.Solid) { obj.PatternType = excelFillStyle; obj.BackgroundColor.SetColor(color); } /// <summary> /// 多列高度設定 /// </summary> public static void Row(this OfficeOpenXml.ExcelWorksheet obj, int StartRow, int EndRow, double Height) { for (int i = StartRow; i <= EndRow; i++) { obj.Row(i).Height = Height; } } /// <summary> /// 多欄寬度設定 /// </summary> public static void Column(this OfficeOpenXml.ExcelWorksheet obj, int StartCol, int EndCol, double Width) { for (int i = StartCol; i < EndCol; i++) { obj.Column(i).Width = Width; } } } |
2016年3月14日 星期一
EPPlus 自訂擴充功能
訂閱:
張貼留言
(
Atom
)
沒有留言 :
張貼留言