How to set a bold string to HeaderFooter.FirstHeader of an Excel File (epplus)?

3.2k views Asked by At

I have an ExcelWorksheet item in C# that I want to add a firstheader in bold. Please note that the header should not be in any row, the content will start at Row1.

I am adding the header like:

ExcelWorksheet w;
w.HeaderFooter.FirstHeader.CenteredText = "My Text";

However, I could not find out how to make the content: My Text bold. There is no .Bold or .FontSize, or .Style kinda property anywhere that I can set the font style as bold. I found the picture below in the documentation, but I am not successful to reach the listitems in the code as well.

enter image description here

I have tried to set my text as: "<b>My Text</b>", but no luck, did not work. Couldn't find an example online. Any help or advice would be appreciated.

1

There are 1 answers

2
Tomato32 On BEST ANSWER

You can try set following this. Hope to help, my friend :))

worksheet.HeaderFooter.FirstHeader.CenteredText = "&18&U&\"Tahoma,Regular Bold\" Inventory";
  • 18: font size
  • U: underline
  • Font Tahoma
  • Bold :))