TRichString Class
A string cell value with its rich text information. RTFRuns is an array of TRTFRun structures, where each struct identifies a font style for a portion of text. For example, if you have: Value = "Hello" RTFRuns = {FirstChar:1 FontIndex:1, FirstChar:3, FontIndex:2} "H" (char 0) will be formatted with the specific cell format.
"el" (chars 1 and 2) will have font number 1 "lo" (chars 3 and 4) will have font number 2
Syntax
Namespace: FlexCel.Core
public class TRichString: ICloneable, IConvertible
Constructors
Name | Description |
---|---|
TRichString | Overloaded TRichString TRichString(String) TRichString(String, TRTFRun[], ExcelFile) TRichString(String, TRichString, Int32) |
Methods
Name | Description |
---|---|
FromHtml | Returns a new TRichString from an HTML text. Note that only some tags from HTML are converted, the ones that do not have correspondence on Excel rich text will be discarded.Note: This method is for advanced uses only. Normally you would just use ExcelFile.SetCellFromHtml(Int32, Int32, String, Int32) |
RTFRun | A run of RTF. |
SetRTFRun | Sets one RTF run. |
GetFont | Return the font for a font index. |
GetFontForChar | Returns the index of the run for the character charIndex in the string. If there is no font for the character, it will return -1. |
ToString | Returns the string without Rich text info. |
Substring | Overloaded Substring(Int32) Substring(Int32, Int32) |
Add | Adds two richstrings together. If using C#, you can just use the overloaded "+" operator to concatenate rich strings. |
Trim | Trims all the whitespace at the beginning and end of the string. |
RightTrim | Trims all the whitespace at the end of the string. |
Replace | Overloaded Replace(String, String) Replace(String, String, Boolean) |
SetFromHtml | Sets the rich string content from an HTML Formatted string. Note: This method is for advanced uses only. Normally you would just use ExcelFile.SetCellFromHtml(Int32, Int32, String, Int32) |
ToHtml | Overloaded ToHtml(ExcelFile, TFlxFormat, THtmlVersion, THtmlStyle, Encoding) ToHtml(ExcelFile, TFlxFormat, THtmlVersion, THtmlStyle, Encoding, IHtmlFontEvent) |
Clone | Returns a Deep copy of the Rich string. |
Equals | Returns true when both richstrings are equal. |
GetHashCode | Hashcode for this richstring. |
Operators
Name | Description |
---|---|
Addition | Concatenates two TRichString objects. Be careful that formats will be preserved from s1 to s2. If s1 ends up in red, s2 will start with red too. If you want to avoid this, make sure s2 has a font definition at character 0. ALSO, MAKE SURE YOU ARE CONCATENATING RICH STRINGS FROM THE SAME WORKBOOK, SO FONT INDEXES ARE SIMILAR. |
Implicit Conversion | Overloaded Implicit conversion from String to TRichString Implicit conversion from TRichString to String |
Equality | Returns true if both RichStrings are equal. Note this is for backwards compatibility, this is a class and not immutable, so this method should return true if references are different. But that would break old code. |
Inequality | Returns true if both RichStrings do not have the same value. Note this is for backwards compatibility, this is a class and not immutable, so this method should return true if references are different. But that would break old code. |
Properties
Name | Description |
---|---|
Value | Text of the string without formatting. |
RTFRunCount | Number of RTF runs. |
MaxFontIndex | The count of Fonts on the richstring. |
this[] | Returns the character at position index. |
Length | Length of the RichString. |
IsEmpty | Returns true if the string is empty. |