HTML content gets stripped when using setHtmlString – text after '<' is removed

Hello Aspose Support Team,

We are facing an issue while using setHtmlString on Excel cells, where part of the text gets unexpectedly stripped.

Issue Description

For certain column indexes, we convert plain text to HTML using setHtmlString . However, when the cell value contains comparison operators like < and > , part of the content is lost after setting the HTML string.

Example

Original cell value:

Exceeded : >=20% | Fully Met : 15% - 20% | Partially Met : <10%

Actual result after setHtmlString:

Exceeded : >=20% | Fully Met : 15% - 25% | Partially Met :

The portion <10% is completely removed.

Code Snippet

(htmlToTextIndices || []).forEach((colIndex) => {
    const cell = sheet.getCells().get(row, colIndex);
    if (cell.getValue() !== null && cell.getValue() !== '') {
        let currentValue = cell.getStringValue();
        currentValue = currentValue
            .replace(/<div>/gi, '<p>')
            .replace(/<\/div>/gi, '</p>');
        cell.setHtmlString(currentValue);
    }
});

Observation

It appears that values containing < are being treated as invalid or incomplete HTML, causing Aspose to strip that portion of the string.

Expected Behavior

The full text, including values like <10% , should be preserved and rendered correctly in the cell.

Request

Could you please:

  1. Suggest the correct or recommended way to safely handle such strings
  2. Let us know if there is a workaround or fix available

Looking forward to your guidance on this issue.

@KarthikMunjam

  • Are you using Aspose.Cells for JavaScript or another environment (e.g., .NET/Java with a JavaScript-like syntax in a different runtime)?
  • Does the issue occur only at specific column indexes, or is it reproducible regardless of column position when < is present?
  • Is the input string containing <10% being interpreted as an HTML tag, and have you tried HTML-encoding the < and > characters (e.g., using &lt; and &gt;) before passing to setHtmlString?
  • Can you confirm whether the cell’s final HTML output (if inspectable) shows malformed tags or stripped content after execution?
  1. Yes am using Aspose.Cells for Node Js via JAVA
  2. it reproducible regardless of column position when < is present
  3. I need alternate solution
  4. stripped content after execution

@KarthikMunjam

Пользователь столкнулся с проблемой потери текста после символа ‘<’ при использовании метода setHtmlString в Aspose.Cells. Он предоставил воспроизводимый сценарий, код и чётко указал, что ему требуется альтернативное решение. Это технический запрос на устранение неполадки в коде.

@amjad.sahi can you please help here

@KarthikMunjam,

Could you please give me final HTML string that you are setting to the cell via setHtmlString method? By the way, I used the following line of code and it works fine and as expected.

cell.setHtmlString("<td>Exceeded : &gt;=20% | Fully Met : 15% - 20% | Partially Met : &lt;10%</td>"); 

i used this

Exceeded : >=20% | Fully Met : 15% - 20% | Partially Met : <10%

@KarthikMunjam,

Thanks for sharing further details.

I replicated the problem you described using a simple template file (attached) that has your original value in cell A1 of the first worksheet. I discovered that the HTML content gets stripped from the output Excel file when using Cell.setHtmlString – any text following ‘<’ is removed. Here is the relevant Aspose.Cells for Java code:

Workbook workbook = new Workbook("d:\\files\\Bk_contents1.xlsx");
Cells cells = workbook.getWorksheets().get(0).getCells();
Cell cell = cells.get("A1");
if (cell.getValue() != null && cell.getValue() != "") {
String currentValue = cell.getStringValue();
cell.setHtmlString(currentValue);
}
workbook.save("d:\\files\\out1.xlsx");

Bk_contents1.zip (6.2 KB)

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNODEJSJAVA-90

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi when i expect this fix ,
as we are also planning for the upgrade of aspose

as we have discussed in the above forum

@KarthikMunjam,

Thank you for your patience as we need little time to thoroughly evaluate your issue. We are hopeful it will be resolved soon. As soon as we have any updates or an estimated timeframe, we will inform you here.

I’m planning to upgrade the aspose. Which version should we purchase? If we buy the current stable version (25.10), will it include the fix, or will we need a newer release?
Any ETA for the Issue ?

@KarthikMunjam,

No, version 25.10 will not have the fix as it is an older version. The most recent version/fix is Aspose.Cells for Node.js via Java 25.12. The fix may be included in future releases like 26.1 or 26.2. You can upgrade from version 24.0 and purchase a new license to use 25.12 for now. Once the fix is added in a future release, you can easily update your application to the latest version. Please note, that when you buy a license for a product, you are entitled to use new versions and fixes for free for the next whole year.

Regarding ETA, once we have it, we will share it with you.

@KarthikMunjam ,

This it to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v26.1) that we plan to release in the first half of January 2026. You will be notified when the next version is released.
The result after applying the fix is attached for your review:
output.zip (6.5 KB)

cool , thank you

@KarthikMunjam,

You are welcome. We’ll make sure to keep you updated on the new release as soon as it’s available.

The issues you have found earlier (filed as CELLSNODEJSJAVA-90) have been fixed in this update. This message was posted using Bugs notification tool by duojie.yang