excel - 为什么我的背景颜色没有应用(Aspose Cells)?

标签 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

不过,有些事情正在发生,因为看起来单元格边界垂直线的中间部分已被删除。我不知道为什么,或者是否与浅蓝色令人难以忍受的隐形有任何联系。在添加该代码(第一个片段)之前,这些污迹/删除是不可见的。

最佳答案

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

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

关于excel - 为什么我的背景颜色没有应用(Aspose Cells)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41572571/

相关文章:

excel - "=+IF(...)"在 Excel 中有什么作用吗?

html - 谁能找到这个空白是从哪里来的?

CSS线性渐变 Angular 位置

python - 通过 Python 模块 xlwt 更改 xls 文件中的默认分页符

vba - 使用 LastRow 自动填充

android - 如何使用 android 中的 aspose 库在 excel 工作表的列中插入值列表?

java - Aspose xlsx和pptx文件转换异常

java - 将 Docx 文件转换为图像

vba - 过滤数字字段

iphone - UIViewController 的背景到分组 TableView 颜色