Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: How to bold specific text inside a cell and delete some html tags after bolding

$
0
0
Hi,

Can I ask how can i bold a specific text inside a cell? i know that it can be accomplish by
            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "<b>test</b>" + System.Environment.NewLine + "test1";
            worksheet.Cell("A1").RichText.Substring(3, 4).SetBold(true);
as what you can see my cell value contains html tags and i can set "test" as bold using substring as per the documentation states. my problem is i needed to delete the <b> tags right after i bold the "test" string. i tried
worksheet.Cell("A1").RichText.Substring(3, 4).SetBold(true).ToString().Remove(1,2);

and

worksheet.Cell("A1").Value=worksheet.Cell("A1").RichText.Substring(3,4).SetBold(true).ToString().Remove(1, 2);
but doesnt work. can someone help me pls.

thanks

Viewing all articles
Browse latest Browse all 1877

Trending Articles