We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTMLString - multiple formats in single cell

Good afternoon,

We have a requirement to process replacements in a cell such as

#Format(This is some text {placeholder} and more text)

As you can see above we have some text in bold and some text in normal weight. When we process these replacements the formatting is not persisted and the full cell text comes out as bold.

If i update the HTMLString manually (at breakpoint) and put 'font-weight: normal' on the second style element then the cell formats correctly.

Is this an issue with Aspose or is there a specific way we shuld be implementing this.

lease find attached a sample prject that demonstrates the HTMLString not being persisted.

Thanks in advance,

Danny Brown.


Thanks for providing us the sample project here.

I have found the issue after an initial test, we will figure it out soon.

I have logged your issue into our issue tracking system with an issue id: CELLSNET-17308.

Thank you.


After further investigation we come to know that It’s not an issue of Aspose.Cells. The Cell.StringValue does not inculde any font setting. The Cell.PutValue does not change the font setting too.

If you want to set the rich text formatting, please check the document: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/formatting-selected-characters-in-a-cell.html

And you can try the following sample code with Cell.HtmlString to implement your requirement.

Workbook book = new Workbook();


Worksheet sheet = book.Worksheets[0];

Aspose.Cells.Cell cell = sheet.Cells[0, 0];

string cellText = cell.HtmlString;

Aspose.Cells.Cell formattedCell = sheet.Cells[1, 0];


string newCellText = cellText.Replace("#Format(", string.Empty);

newCellText = newCellText.Replace("{ReportingUnit}", “This text should not be bold”);

newCellText = newCellText.Replace(")", string.Empty);

formattedCell.HtmlString = newCellText;


Thank you.