开发者

FormatCondition Font Bold from C# Excel Interop not working

开发者 https://www.devze.com 2023-03-14 13:10 出处:网络
I\'m adding a new FormatCondition to a cell and trying to set som开发者_如何学编程e formatting:

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号