2017/01/20

[C#]EPP Plus

設定寬度:ws.Column(1).Width = 20; //不是像素
設定垂直對齊:ws.Cells[RR, CC].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
設定自動欄寬:ws.Cells["B1"].AutoFitColumns();
設定文字粗體:ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;

先引用 using System.Drawing;  再使用以下指令
設定文字顏色:ws.Cells["A1:B1"].Style.Font.Color.SetColor(Color.White);
設定填滿顏色:ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(0, 66, 177));
設定自動換行:ws.Cells[RR, CC].Style.WrapText = true; 
字串斷行 à “\n”:ws.Cells[RR, CC].Value = SourceTable.Rows[R[C].ToString().TrimEnd('>').Replace("<br/>"," \n ").Replace("<br/", "");

沒有留言: