Hi,
The following Aspose.Cells code throws an error. The cause is the CSS color string color:#ff00000 !important
part of the HTML
var xls = new Workbook();
var sheet = xls.Worksheets.First();
var row = sheet.Cells.Rows[0];
row[0].HtmlString = @"<span style=""color:#ff0000"">TEST</span>"; // OK
row[0].HtmlString = @"<span style=""color:rgb(17,17,17)"">TEST</span>"; // OK
row[0].HtmlString = @"<span style=""color:#ff0000 !important;"">TEST</span>"; // <== ERROR
row[0].HtmlString = @"<span style=""color:rgb(17,17,17) !important"">TEST</span>"; // <== ERROR
row[0].HtmlString = @"<span style=""color:#ff0000!important;"">TEST</span>"; // <== ERROR
row[0].HtmlString = @"<span style=""color:rgb(17,17,17)!important"">TEST</span>"; // <== ERROR
The error depends on the actual string passed. You can have:
Unhandled exception. System.ArgumentException: Convert invalid primitive (Parameter 'text') (Parameter 'htmlColor')
---> System.ArgumentException: Convert invalid primitive (Parameter 'text')
---> System.FormatException: Additional non-parsable characters are at the end of the string.
at System.ParseNumbers.StringToInt(ReadOnlySpan`1 s, Int32 radix, Int32 flags, Int32& currPos)
at System.Convert.ToInt32(String value, Int32 fromBase)
at ♥☻.☻(String ☻, Int32)
at ♥☻(String ☻, CultureInfo)
--- End of inner exception stack trace ---
at ♥☻(String ☻, CultureInfo)
at ♥☻.☻(String ☻, CultureInfo)
at ♥☻.☻(String ☻)
--- End of inner exception stack trace ---
at ♥☻.☻(String ☻)
at Aspose.Cells.Drawing.ColorHelper.☻(String ☻)
at Aspose.Cells.Drawing.ColorHelper.☻(String ☻)
at→▬.☻(String ☻)
at→▬.☻(WorksheetCollection ☻, Font, Hashtable ♣, Hashtable ♠)
at→▬.☻(Shape ☻, WorksheetCollection, Font ♣, Char[] ♠, ArrayList ♥, Hashtable )
at→▬.☻(Cell ☻, String, Hashtable ♣)
at Aspose.Cells.Cell.set_HtmlString(String value)
or
Unhandled exception. System.FormatException: The input string '17)!importan' was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
at System.Int32.Parse(String s)
at→▬.☻(String ☻)
at→▬.☻(WorksheetCollection ☻, Font, Hashtable ♣, Hashtable ♠)
at→▬.☻(Shape ☻, WorksheetCollection, Font ♣, Char[] ♠, ArrayList ♥, Hashtable )
at→▬.☻(Cell ☻, String, Hashtable ♣)
at Aspose.Cells.Cell.set_HtmlString(String value)
color:#ff0000 !important
or color:#ff00000!important
(without the space) are all valid values according to the W3C Validator and should be supported, or at the very least, not throw an error.
Thanks.
–
Tested with Aspose.Cells 23.3.0 and 24.1.0.0