List<string> ems = new List<string> { "0.5", "0.7", "0.900", "1.0", "1.1", "1.500", "2.0", "2.1" };
foreach (var em in ems)
{
try
{
string html = $"<span style=\"color: red; font-size: {em}em; \">ROT und Groß</span>";
Console.WriteLine(html);
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
wb.Worksheets[0].Cells[1, 0].HtmlString = html;
Console.WriteLine($"working for {em}em");
}
catch (Exception ex)
{
Console.WriteLine($"NOT working for {em}em!!");
Console.WriteLine($"ERROR: {ex.Message}");
}
}
I am getting a “Font size is out of range.” error for all em values smaller than 1.0 when setting Cell.HtmlString.
I’ve testet with latest Aspose.Cells .Net version (22.6.1).
I did test your sample code and it works except for the first three values in the list, see the output for the error values: ouput:
NOT working for 0.5em!!
ERROR: Font size is out of range. ROT und Groß
NOT working for 0.7em!!
ERROR: Font size is out of range. ROT und Groß
NOT working for 0.900em!!
ERROR: Font size is out of range.
The output is right. Please note, MS Excel only supports font size range >= 1 and <=409 points. For confirmation, you may open a workbook and try to set font size (for some cell value in the sheet) to, e.g., “0.5” and you will get an error message by MS Excel:
“Font size must be between 1 and 409 points”.
In short, the following values cannot be set for font size:
Let us know if you still have any issue or confusion.
please note, that this is about a font-size in “em” and not in “points”! Excel specifically warns you about font-sizes smaller than “1pt”; not smaller than “1em”.
Because 1em = 12pt = 16px, 0.5em should generally be roughly 6pt or 8px and thus well above the 1pt minimum specified by MS Excel.
I now understand you that you are using em unit for specifying font size (previously I overlooked it). I am able to reproduce the issue as you mentioned. I am getting a “Font size is out of range.” error for all em values smaller than 1.0 when setting Cell.HtmlString. It should work fine as 0.5em should be equal to 6pt (approx.).
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): CELLSNET-54972
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.
We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v24.2) that we plan to release in the first half of February 2024. You will be notified when the next version is released.
The issues you have found earlier (filed as CELLSNET-54972) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi