Table of Contents

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

Methods

Name Description
Add Adds two richstrings together. If using C#, you can just use the overloaded "+" operator to concatenate rich strings.
Clone Returns a Deep copy of the Rich string.
Equals Returns true when both richstrings are equal.
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.​Set​Cell​From​Html(​​Int32, Int32, String, Int32)
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.
GetHashCode Hashcode for this richstring.
Replace Overloaded
Replace(String, String)
Replace(String, String, Boolean)
RightTrim Trims all the whitespace at the end of the string.
RTFRun A run of RTF.
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.​Set​Cell​From​Html(​​Int32, Int32, String, Int32)
SetRTFRun Sets one RTF run.
Substring Overloaded
Substring(Int32)
Substring(Int32, Int32)
ToHtml Overloaded
ToHtml(ExcelFile, TFlxFormat, THtmlVersion, THtmlStyle, Encoding)
ToHtml(ExcelFile, TFlxFormat, THtmlVersion, THtmlStyle, Encoding, IHtmlFontEvent)
ToString Returns the string without Rich text info.
Trim Trims all the whitespace at the beginning and end of the string.

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.
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.
Implicit Conversion Overloaded
Implicit conversion from String to TRichString
Implicit conversion from TRichString to String
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
IsEmpty Returns true if the string is empty.
Length Length of the RichString.
MaxFontIndex The count of Fonts on the richstring.
RTFRunCount Number of RTF runs.
this[] Returns the character at position index.
Value Text of the string without formatting.