Aspose.Cells 設置背景顏色


 很多小伙伴設置背景顏色都不起作用,特別提醒需要加入下面一行:

style.Pattern = BackgroundType.Solid;
Aspose.Cells.Style style = null;
int index = workbook.Styles.Add();
style = workbook.Styles[index];
//文本顏色
style.Font.Color = Color.Red;
style.Font.Size = 10;
//設置背景顏色
style.ForegroundColor = System.Drawing.Color.Silver;
style.Pattern = BackgroundType.Solid;
style.Font.IsBold = true;
style.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Center;
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //應用邊界線 左邊界線 
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; //應用邊界線 右邊界線 
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; //應用邊界線 上邊界線 
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //應用邊界線 下邊界線
Aspose.Cells.Range w = cells.CreateRange(row, col, 1, 1);
w.ApplyStyle(style, new StyleFlag() { All=true});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM