Testing To determine if a FontStyle is applied

Posted by: rodneybuxton on 8 September 2017, 2:42 pm EST

  • Posted 8 September 2017, 2:42 pm EST

    How can I test in an IF statement to see if a particular FontStyle is applied to a cell.  Specifically I want to determine if .Bold has been applied to a cell.  If it has then I want to do something with that cell.

    I tried something like:

     If fpsProperties.ActiveSheet.Rows.Get(i, 2).Font.Bold Then

                    'do something here

     End If

     

    But this clearly didn't work. 

  • Replied 8 September 2017, 2:42 pm EST

    Hi,

    You need to use SheetView.GetStyleInfo or ISheetStyleModel.GetCompositeInfo to get the composite style for the cell, then check the StyleInfo.Font.

    The Font property (and other style properties) for Cell, Column, Row, AlterntingRow, and SheetView.DefaultStyle gets or sets the "direct" setting applied to the style model for the specified part of the control.  Those "direct" settings are composed into one composite style used for actually painting the cell, so that settings from higher levels are inherited at lower levels (unless they are overridden at the lower level).  The Font property is inherited as an object, so its individual style properties are not merged in this way, but a font set for a Cell will override the font set for the Column or Row or AlternatingRow.

    For more information about style property inheritance in Spread, please refer here:

    http://www.gcpowertools.com/Help/S5/spwin-knowobjparentage.html

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels