Tag: background foreground

为什么设置一个单元格的颜色不起作用(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; …但都没有做任何事情 – 单元格看起来和上面的截图完全一样。

为什么我的字体和背景(前景)着色不起作用(Aspose Cells)?

在我的工作表的两个地方,我需要有白色字体和黑色背景的单元格。 在一个地方(标题行),它起作用; 在另一个(date值),它没有,我不明白我在做什么不同,会导致这种失败。 这是正在工作的代码(对于标题行): CellsFactory cfHeaderRow = new CellsFactory(); Cell headerRowCell; Style styleHeaderRow; for (int x = 0; x < drPrices.FieldCount-1; x++) { headerRowCell = pricePushSheet.Cells[6, x]; headerRowCell.PutValue(drPrices.GetName(x)); pricePushSheet.Cells.SetColumnWidth(x, 9); styleHeaderRow = cfHeaderRow.CreateStyle(); styleHeaderRow.HorizontalAlignment = TextAlignmentType.Center; styleHeaderRow.Font.Color = Color.White; styleHeaderRow.ForegroundColor = Color.Black; styleHeaderRow.Pattern = BackgroundType.Solid; styleHeaderRow.IsTextWrapped = true; headerRowCell.SetStyle(styleHeaderRow); } ..这里是不工作的代码(对于在下面的屏幕截图中圈出的date行): CellsFactory cfDate = new […]