Free Support Forum -

Format string (color- font ... ) pass in a cell

I want to format cell as in a below picture

cells[0, 0].PutValue("???");
cells[0, 0].Style.

Thanks with reading and helps.


Please see the code below, I have made use of the Cell.HtmlString property to achieve this result.

I have also attached the output file and the screenshot. The code is fully commented, so you will not have a trouble getting it.


//Create a workbook
Workbook workbook = new Workbook();

//Access its worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Access cell A6
Cell cellA6 = worksheet.Cells[“A6”];

//Use HtmlString property to set the stylish text using html
cellA6.HtmlString = “<font style=‘color:red’>Red <font style=‘color:blue’>Blue <font style=‘color:green’>Green <font style=‘font-style:bold’>Bold <font style=‘font-style:italic’>Italic”;

//Save the workbook

workbook.Save("f:\\downloads\\output.xlsx", SaveFormat.Xlsx);


And, if you want to use cells’ style/formatting to achieve your requirement, you may see the following topic:

thank you.

Thank you very much.