Search code examples
c#npoi

How can i set a color in header string in NPOI?


I want to set a color for font and I used IHeader i have no idea how to set a color using &K. Please help and make a string to set a color to header font.

header.Right = "PRIVILEGED AND CONFIDENTIAL"+ "\r\n " + "ATTORNEY WORK-PRODUCT ";

Solution

  • Colors can be specified inline using

    &K[RRGGBB]
    

    with RRGGBB the hexadecimal color encoding, as you would use in (for example) HTML. Most color selection dialogs in drawing programs or online will tell you the RRGGBB value of a color.

    Example code:

    IHeader header = sheet.Header;
    header.Center = "This is a &K0000FFblue text";