HtmlString and Font-Family

I have the following HTML value added by one of our clients that generates an issue when opening up the Excel file:

<span style="font-family: 'Segoe UI', Arial, Helvetica, sans-serif; font-size: 12px;">Text was entered here</span>

I have traced the issue to the fact that there are 4 fonts described in the style attribute of the span tag.

My question is:

  • Are you able to modify the HtmlString function to strip the 2nd and subsequent font name from the font-family?

Update: The issue is actually the number of fonts declared - with the maximum being 3. The example above causes a problem, but remove one of the fonts, and it is fine.

@BCM_Solutions

We have tested this issue with the following sample code and found, it generates corrupt Excel file.

We have logged this issue in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-45749 - Html String having multiple Fonts corrupts the output Excel file

Download Link:
Corrupt Output Excel File.zip (5.6 KB)

C#

string strHTML = "<span style=\"font-family: 'Segoe UI', Arial, Helvetica, sans-serif; font-size: 12px;\">Text was entered here</span>";

Workbook wb = new Workbook();

Worksheet ws = wb.Worksheets[0];

Cell cell = ws.Cells["B2"];
cell.HtmlString = strHTML;

wb.Save("corrupt.xlsx");

Screenshot:

@BCM_Solutions

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSNET-45749 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSNET-45749) have been fixed in this Aspose.Cells for .NET 17.11 update.

Please also check the following article: