We recently moved to LibXL version 3.9, which adds support to styled text for use in Excel files. We added a new XLRichStringMBS class to have all the options available within the LibXL library. But we also added support for working with StyledText class directly.
You can just pass the styled text from a TextArea control directly to be used to set a cell in your document. Same for reading, where we translate the styles back. Here is an example to write a cell:
[code]Dim st As New StyledText
Dim row As Integer = 2
Dim col As Integer = 0
st.Text = “Red Text blue”
st.TextColor(0, 8) = &cFF0000
st.TextColor(9, 4) = &c0000FF
st.Size(0,4) = 15
Call sheet.WriteStyledText row, col, st
row = 3
st = New StyledText
st.Text = “Hello World from Xojo”
st.Italic(0,11) = True
st.Bold(0,11) = True
st.Underline(0,11) = True
st.Font(0,11) = “Calibri”
st.Bold(12,10) = True
Call sheet.WriteStyledText row, col, st[/code]
The XLRichStringMBS class allows you to use a XLFontMBS class with the following styling properties to be used: color, italic, bold, single/double underline, strikeout, font name, sub/superscript and font size. Converting from StyledText we pass through bold, italic, underline, font name, size and color. When you call WriteStyledText, you can optionally include a format object, which defines e.g. alignment.
Please try the new functionality and don’t hesitate to contact us with questions. This is already included in 20.2pr4 download.