Reputation: 21
I want to insert rich text in a range of my excel sheet, not in particular cell.
for eg: I want to insert ABCDEFGH; IJKLMNOPQ
in a range where AB...H will come in red
color and IJ....Q will come in blue
color.
How will i implement it using closedxml ?
Upvotes: 1
Views: 1674
Reputation: 87
try this please
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Sample Sheet");
worksheet.Cell("B2").RichText.AddText("ABCDEFGH; ").SetFontColor(XLColor.Red);
worksheet.Cell("B2").RichText.AddText("IJKLMNOPQ").SetFontColor(XLColor.BabyBlue);
worksheet.Range(worksheet.Cell("B2"), worksheet.Cell("H2")).Merge();
workbook.SaveAs(@"c:\temp\HelloWorld3.xlsx");
Upvotes: 2