I have a specific column where data comes in with basic html tags. when I convert that to excel…I see tags in the string. styles were not applied. How to apply styles in aspose cells. Kindly help
Example:
Request :
worksheet.Cells[“A1”].PutValue(“HTML Text”);
worksheet.Cells[“A2”].PutValue(“Bold Text”);
worksheet.Cells[“A3”].PutValue(“Italic Text”);
worksheet.Cells[“A4”].PutValue(“Red Text”);
Response:
HTML Text
Bold Text
Italic Text
Red Text
@immoses,
Please use Cell.HtmlString property instead of PutValue method to set HTML tags. See and try the following sample code that works fine as I tested.
e.g.
Sample code:
Workbook workbook1 = new Workbook();
Worksheet worksheet = workbook1.Worksheets[0];
worksheet.Cells["A1"].PutValue("HTML Text");
worksheet.Cells["A2"].HtmlString = "<b>Bold Text</b>";
worksheet.Cells["A3"].HtmlString = "<i>Italic Text</i>";
worksheet.Cells["A4"].HtmlString = "<font color='red'>Red Text</font>";
workbook1.Save("g:\\test2\\out1.xlsx");
Hope, this helps a bit.
1 Like