2016-11-23 9 views
0

나는 (무엇보다도) 셀의 배경색을 설정하려고하는이 코드를 가지고 :셀에 색상 설정이 작동하지 않는 이유는 무엇입니까 (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); 

수평 및 수직 정렬 작업의 설정, 대담하고 높이처럼 - 컬러하지만 모든 :

enter image description here

아직 필요한 것은 무엇입니까? 난에, 배경 색상뿐만 아니라 foregroundColor의 설정을 시도했다 :

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

...하지만 둘 다 아무것도하지 않는다 - 셀은 아직 정확히 위의 스크린 샷과 같은 보인다.

답변

2

(강조 표시된 라인 참조) 코드 세그먼트를 변경하십시오 예컨대 샘플 코드 :

. . . 
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에서 developer/Evangelist로 일하고 있습니다.