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

Free Support Forum - aspose.com

Multiformat text in the same cell

Based on the currently available “tools” in the Aspose.Cells framework I find it a bit limiting and convoluted working with creating multi-format text in a cell. I created a few helpers which makes it easy to write such code but I am still asking myself if I am using the framework optimally or as the Aspose developers intended it.
It’s hard to find a good tutorial or complex example. Let’s get past the simple examples of changing the color of the text from index1 to index2.
A real example where someone wants to build a multiformated text in a cell.
Can we get a full fledged example?

Thank you!


Thanks for your query.

You may please use HtmlString property of a cell to set the multiformat text as shown in the following sample. Please give it a try and provide your feedback.

// Create and object of the target workbook
var destWb = new Workbook();

// Access first worksheet from the collection
var _sheet = destWb.Worksheets[0];
// Use Html string
_sheet.Cells["A1"].HtmlString = "<Font Style=\"FONT-FAMILY: Arial;FONT-SIZE: 12pt;COLOR: #ff0000;\">Hello</Font><Font Style=\"FONT-WEIGHT: bold;FONT-FAMILY: Arial;FONT-SIZE: 28pt;COLOR: #ff0000;\">Hello</Font><Font Style=\"FONT-WEIGHT: bold;FONT-FAMILY: Arial;FONT-SIZE: 12pt;COLOR: #00b050;\">Hello</Font>";

// Save the workbook on disc
destWb.Save(path + "outputPartialTextFormatting.xlsx");

Capture.PNG (2.1 KB)


If you want to accomplish the task using data formatting APIs, see the sub-topic with the example code for your reference:

Hope, this helps a bit.