为什么设置一个单元格的颜色不起作用(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); 

水平和垂直alignment工作的设置,如大胆和高度 – 除了颜色之外,

在这里输入图像说明

还需要什么? 我甚至尝试设置ForegroundColor以及背景颜色,以:

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

…但都没有做任何事情 – 单元格看起来和上面的截图完全一样。

请将您的代码段更改为(请参阅突出显示的行):例如代码:

 . . . 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担任Support developer / Evangelist。