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

Free Support Forum - aspose.com

Error setting Cell.HtmlString for em font sizes smaller 1.0

Hi,
have a look at this code:

        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).

Thanks and best regards
Udo

@u.engelhardt,

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.