FormatCondition Font Bold from C# Excel Interop not working
I'm adding a new FormatCondition to a cell and trying to set som开发者_如何学编程e formatting:
Excel.FormatCondition cond = ExcelUtils.AddConditionExpression( .... );
cond.Font.Color = 5287936;
cond.Font.Bold = true;
Setting the color works fine, setting Bold to true doesn't (cond.Font.Bold is still System.DBNull after the assignment) and when I inspect the newly created conditional formatting in Excel I only see the color.
Has this happened to anyone else ? Please help!
Thanks
Try using Microsoft.Office.Core.MsoTriState.msoTrue
instead of the plain Boolean value of true. MS Word interop has similar requirements. In the case of a Word Range, you have to cast the Bold value to an integer:
textRange.Font.Bold = (int) Microsoft.Office.Core.MsoTriState.msoTrue;
精彩评论