Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
Cell Font Colours
posted

Hi,

I am trying to change the color of a font when creating a worksheet and am using the command

cell(x).cellformat.font.color = color.red, which results in a warning but seems to work.

Warning 2 'Public Property Color As System.Drawing.Color' is obsolete: 'The IWorkbookFont.Color is deprecated. It has been replaced by IWorkbookFont.ColorInfo.'.

changing to

cell(x).cellformat.font.colorinfo.color = color.ref gives  the error

Property Color is read only.

Anyone know how to fix this? I've tried creating a colorinfo object but cannot assign to the color property here either.

Parents
No Data
Reply
  • 44743
    Verified Answer
    posted

    You must assign the WorkbookColorInfo object to the ColorInfo property, like so:

    cell(x).CellFormat.Font.ColorInfo = new WorkbookColorInfo(Color.Red)

     

Children