HTML Rich Text inside the Aspose Cell does not support correct indent and line breaks [Excel]

For a given worksheet of type Aspose.Cells.Worksheet , the value of cell can not parse HTML enrich text properly.

Approach:

string value = "This is test<div><ul><li>Item 1<ul><li>item 1.1</li><li>item 1.2</li></ul></li><li>Item 2<ul><li>item 2.1</li><li>item 2.2</li></ul></li></ul></div>";
worksheet.Cells[1,1].HtmlString =  value; 

Expected output in excel cell:
This is test

  • Item 1
    • item 1.1
    • item 1.2
  • Item 2
    • item 2.1
    • item 2.2

But, actual output in excel cell is not indented properly. See attached screenshot.

Value for Font: <Font Style="FONT-FAMILY: Arial;FONT-SIZE: 9pt;COLOR: #262626;TEXT-ALIGN: left;Background-Color: #f2f2f2;"></Font>

Screenshot 2024-01-16 192727.png (996 Bytes)

How can we resolve this ? Is it possible from Aspose Cells ?
Looking forward for your help in this issue.

@riteshshrestha,

Could you please insert a few line breaks in your HTML string, so Aspose.Cells could work properly. See the following sample code that may work Ok:
e.g.
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

string value = "This is test<br><div><ul><li>Item 1<br><ul><li>item 1.1</li><li>item 1.2</li></ul></li><li>Item 2<br><ul><li>item 2.1</li><li>item 2.2</li></ul></li></ul></div>";
//Insert the HTML string into B2 cell
worksheet.Cells[1,1].HtmlString =  value;

//Extend column width a bit
worksheet.Cells.SetColumnWidth(1,17);
//Aut-fit second row and second column
worksheet.AutoFitRow(1);
worksheet.AutoFitColumn(1);

workbook.Save("g:\\test2\\out1.xlsx");

Hope, this helps a bit.

@riteshshrestha
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): CELLSNET-55111

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.

@riteshshrestha ,

We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v24.3) that we plan to release in the first half of March 2024. You will be notified when the next version is released.
Attached is the result after fix for your refercence: CELLSNET-55111.zip (6.1 KB)

1 Like

Thank you for the update @Eric.wang I really appreciate your support and look forward to the release of Aspose.Cells v24.3 :smiley:

@riteshshrestha
You are welcome. If you have any questions, please feel free to contact us.

In my opinion you need to experiment with different methods of inserting HTML rich text into Aspose Cells. This might involve manipulating the HTML content before inserting it into Aspose Cells or using different APIs or options provided by Aspose Cells for HTML conversion.

We have already resolved the issue raised by @riteshshrestha. The fixed will be published in this week or in the next week. Generally, Aspose.Cells follows MS Excel standards and specifications when parsing or rendering HTML. You can open the HTML files directly in MS Excel to check how they look, and you can expect Aspose.Cells to render the same display. Additionally, one can test some HTML strings directly into Aspose.Cells to check if they work. If not, one can make some tweaks (as I initially proposed adding manual line breaks) to accommodate them.

1 Like

The issues you have found earlier (filed as CELLSNET-55111) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

1 Like