2016-11-23 118 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担任支持开发人员/宣传员。

相关问题