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

Free Support Forum - aspose.com

Issue of special characters(<,>) in Cell.HtmlString

Hi Team,

I am assign two html string to different cell. As a result, i got one cell string render properly while other cell string not render formatting and display html string as it is in cell. To run sample application please give reference of Aspose.Cell dll.
You can see generated excle file at ~\ConsoleAspose\ConsoleAspose\bin\Debug\PresentationDownloads

For reference, I have attached sample application. Please suggest.
ConsoleAspose.zip (2.5 MB)


Thanks for the sample project with template file.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. I found Aspose.Cells is not handling some special characters(e.g <,>) in Cell.HtmlString attribute. I have logged a ticket with an id “CELLSNET-46515” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.


After evaluating your issue further, we found it is not an issue with the product. Please encode “><” as “&gt;&lt;” if it’s not a tag or it is just a string (see the document for your reference: https://www.freeformatter.com/html-escape.html), otherwise we process it as an invalid HTML string. See the sample updated code segment which works fine as I tested:
Sample code:

string path = "E:\\test2\\issue of special characters\\ConsoleAspose\\ConsoleAspose\\bin\\Debug\\PresentationTemplate\\MetricExport.xlsx";
            Workbook wb = new Workbook(path);
            Worksheet wsSDRecommendsCriteria = wb.Worksheets[0]; // SiriusDecisions Recommends Criteria

            Aspose.Cells.Cell expanstionCell = null;
            expanstionCell = wsSDRecommendsCriteria.Cells["B9"];
            expanstionCell.HtmlString = "<b>Average deal size in U.S. Dollars: </b>$5K - $250K | <b>Revenue Band for Current Fiscal Year: </b>$50MM - $2B";
            expanstionCell = wsSDRecommendsCriteria.Cells["B10"];
            expanstionCell.HtmlString = "<b>Current Projected Profit Margin: </b>&gt;-10% - &gt;100% | <b>Current Projected Revenue Growth: </b>&gt;-20% - &gt;200% | <b>Primary Revenue Model: </b>No Filter | <b>Primary Sales Channel: </b>No Filter | <b>Average deal size in U.S. Dollars: </b>&lt;$1K - &gt;$500K | <b>Primary Customer Segment: </b>No Filter";
            wsSDRecommendsCriteria.Cells.DeleteRows(1, 2);
            wb.Save("E:\\test2\\issue of special characters\\ConsoleAspose\\ConsoleAspose\\bin\\Debug\\PresentationTemplate\\Test1asdfasdfasdf141.xlsx", SaveFormat.Xlsx);

Hope, this helps a bit.