Menu

How to specify font color

2021-02-18
2021-02-19
  • George Wang

    George Wang - 2021-02-18

    Hello,

    I'm having trouble to specify a text's font color. Here is the code:

    ...
    Style FontStyle;
    FontStyle.font.color = "FFFF0000";
    FontStyle.font.attributes = FONT_BOLD;
    ..
    const size_t FontStyleCode = book.AddStyle(FontStyle);
    ..
    Sheet.BeginRow().AddCell("some text", FontStyleCode).AddCell(..).EndRow();
    ..

    The outputted Excel (.xlsx) has "some text" in bold and black (default). How do I change the text's color to whatever I want?

    Thanks.
    George

     
  • George Wang

    George Wang - 2021-02-19

    I've figured it out that theme should be false, i.e.,
    ..
    Style FontStyle;
    FontStyle.font.color = "FFFF0000";
    FontStyle.font.attributes = FONT_BOLD;
    FontStyle.font.theme = false;
    ..
    const size_t FontStyleCode = book.AddStyle(FontStyle);
    ..

    The outputted text font color ("some text") will follow font.color.

    George

     

Log in to post a comment.