为什么我的背景颜色未应用(Aspose Cells)?

时间:2017-01-10 15:37:45

标签: excel background aspose aspose-cells

我试图在我的细胞背景中添加一种颜色,如下所示:

style.BackgroundColor = Color.LightBlue;
style.Pattern = BackgroundType.Solid;

在更多背景下:

Cell shortNameHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, SHORTNAME_BYDCBYLOC_COL];
shortNameHeaderCell.PutValue("Short Name");
style = cf.CreateStyle();
style.HorizontalAlignment = TextAlignmentType.Left;
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.Name = fontForSheets;
style.Font.IsBold = true;
style.Font.Size = 12;
style.BackgroundColor = Color.LightBlue;
style.Pattern = BackgroundType.Solid;
shortNameHeaderCell.SetStyle(style);

Cell companyNameHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, COMPANYNAME_BYDCBYLOC_COL];
companyNameHeaderCell.PutValue("Company Name");
companyNameHeaderCell.SetStyle(style);

Cell reasonDescHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, REASONDESC_BYDCBYLOC_COL];
reasonDescHeaderCell.PutValue("Reason Description");
reasonDescHeaderCell.SetStyle(style);

Cell transTypeHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, TRANSTYPE_BYDCBYLOC_COL];
transTypeHeaderCell.PutValue("Transaction Type");
style = cf.CreateStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Name = fontForSheets;
style.Font.IsBold = true;
style.Font.Size = 12;
style.IsTextWrapped = true;
style.BackgroundColor = Color.LightBlue;
style.Pattern = BackgroundType.Solid;
transTypeHeaderCell.SetStyle(style);

Cell sumOfQtyOrdHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, QTYORD_BYDCBYLOC_COL];
sumOfQtyOrdHeaderCell.PutValue("Sum of Qty Ord");
sumOfQtyOrdHeaderCell.SetStyle(style);

Cell sumOfQtyShippedHeaderCell = locationWorksheet.Cells[BYDCBYLOC_HEADING_ROW, QTYSHIPPED_BYDCBYLOC_COL];
sumOfQtyShippedHeaderCell.PutValue("Sum of Qty Shipped");
sumOfQtyShippedHeaderCell.SetStyle(style);

然而,淡蓝色未应用:

enter image description here

但是,有些事情正在发生,因为它看起来像是在划分细胞的垂直线的中间部分被删除了。我不知道为什么,或者如果有任何连接与浅蓝色的难以忍受的无形性有关。在添加该代码(第一个代码段)之前,这些污迹/删除不是[可见]。

1 个答案:

答案 0 :(得分:0)

请注意,如果图案是实心的,则应使用Style.ForegroundColor绘制单元格(或范围)。此外,如果pattern不是solid或none,则Style.BackgroundColor应该用于相同的场景。

注意:我在Aspose担任开发人员传播者。