2016-11-23 95 views
0

我有這樣的代碼來嘗試設置單元格的背景顏色(除其他事項外):爲什麼給單元格設置顏色不起作用(Aspose Cells)?

private static readonly Color CONTRACT_ITEM_COLOR = Color.FromArgb(255, 255, 204); 
. . . 
cell = pivotTableSheet.Cells[4, 0]; 
cell.PutValue(AnnualContractProductsLabel); 
style = cell.GetStyle(); 
style.HorizontalAlignment = TextAlignmentType.Center; 
style.VerticalAlignment = TextAlignmentType.Center; 
style.Font.IsBold = true; 
pivotTableSheet.Cells.SetRowHeight(4, 25); 
style.BackgroundColor = CONTRACT_ITEM_COLOR; 
pivotTableSheet.Cells[4, 0].SetStyle(style); 

水平和垂直對齊作品的設定一樣,大膽的和高度 - 一切,但顏色:

enter image description here

還需要什麼?我甚至嘗試設置ForegroundColor以及背景顏色,來:

style.ForegroundColor = Color.Red; 
style.BackgroundColor = Color.Blue; 

...但同樣沒有任何東西 - 細胞仍然看起來完全一樣,上面的截圖。

回答

2

請更改您的代碼段(見高亮行): e.g 示例代碼:

. . . 
cell = pivotTableSheet.Cells[4, 0]; 
cell.PutValue(AnnualContractProductsLabel); 
style = cell.GetStyle(); 
style.HorizontalAlignment = TextAlignmentType.Center; 
style.VerticalAlignment = TextAlignmentType.Center; 
style.Font.IsBold = true; 
pivotTableSheet.Cells.SetRowHeight(4, 25); 
**style.ForegroundColor = CONTRACT_ITEM_COLOR; 
style.Pattern = BackgroundType.Solid;** 
pivotTableSheet.Cells[4, 0].SetStyle(style); 

..........

它應該工作的罰款。

我在Aspose擔任支持開發人員/宣傳員。

相關問題