I'm importing an XLSX file into a database using ClosedXML via an ASP.NET/VB.NET. My customer needs to keep formatting of single cells, so the solution is to use the cell's RichText property.
I wrote a piece of code that should tranform RichText object in a HTML string, but the color information is not returned from ClosedXML (it always returns #FFFF3333 whatever the text color is.
Here is my snippet:
Shared Function RichTextToHTML(ByVal rt1 As IXLRichText) As String
'trasforma una string rich text in html
Dim ret As String = ""
If rt1.Text <> "" Then
For Each rts1 As IXLRichString In rt1
ret &= "<span style='"
If rts1.Bold Then
ret &= "font-weight:bold;"
End If
If rts1.Strikethrough Then
ret &= "text-decoration:line-through;"
End If
ret &= "color:#" & rts1.FontColor.ToString & ";"
ret &= "'>" & rts1.Text & "</span>"
Next
End If
Return ret
End Function
the "rts1.FontColor" never returns the correct color. I also tried with other libraries like SpreadsheetLight, but same result: no color from rich text inside spreadsheet cell.
Any idea?