I use EPPlus for Excel file generation.
I mean I need to convert HTML text (bold, italic, font color, name, size parameters) to Excel Cell. I suppose it needs to create the multi-styled cell, like:
cell text is "hello!"
the style I want is:
he - bold ll - italic o! - red colored font
or (more complex)
hello! - bold ll - italic (also bold) o! - red colored (also bold)
I know about MS OpenXML library (it allows me to do what I need). This is good but bit more complex library for implementation.
Solved! I can use that:
FileInfo fi = new FileInfo(@"c:\Book1.xlsx"); using (ExcelPackage package = new ExcelPackage(fi)) { // add a new worksheet to the empty workbook ExcelWorksheet worksheet = package.Workbook.Worksheets["Inv"]; //Add the headers worksheet.Cells[2, 1].IsRichText = true; ExcelRichText ert = worksheet.Cells[2, 1].RichText.Add("bugaga"); ert.Bold = true; ert.Color = System.Drawing.Color.Red; ert.Italic = true; ert = worksheet.Cells[2, 1].RichText.Add("alohaaaaa"); ert.Bold = true; ert.Color = System.Drawing.Color.Purple; ert.Italic = true; ert = worksheet.Cells[2, 1].RichText.Add("mm"); ert.Color = System.Drawing.Color.Peru; ert.Italic = false; ert.Bold = false; package.Save(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With