2017-01-10 129 views
1

我試圖將顏色添加到我的單元格的背景,像這樣:爲什麼我的背景顏色不適用(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

雖然發生了一些事情,因爲它看起來像是細胞邊界的垂直線的中間部分已經是時代SED。我不知道爲什麼,或者如果與淡藍色的難以忍受的無形性有任何關聯。在添加代碼(第一段代碼)之前,這些污跡/擦除不可見。

回答

1

請注意,如果圖案是固體,應使用Style.ForegroundColor繪製單元格(或範圍)。此外,如果pattern不是固定的或者沒有,Style.BackgroundColor應該用於相同的場景。

注意:我在Aspose擔任開發者推廣者。

相關問題