Syncfusion.XlsIO.Base
Example 


Character index.

GetFont Method (IRichTextString)

Returns font which is applied to character at the specified position.
Syntax
'Declaration
 
Function GetFont( _
   ByVal iPosition As Integer _
) As IFont
'Usage
 
Dim instance As IRichTextString
Dim iPosition As Integer
Dim value As IFont
 
value = instance.GetFont(iPosition)
IFont GetFont( 
   int iPosition
)

Parameters

iPosition
Character index.

Return Value

Font which is applied to character at the specified position.
Exceptions
ExceptionDescription
Since the IFont object returned by GetFont method is read-only Argument out of range exception will occur if it is modified
Remarks
Font style can be changed by cloning the font obtained using GetFont method and to be set using SetFont method.
Example
The following code illustrates how to access GetFont method.
using Syncfusion.XlsIO;
using System;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set text
            worksheet["C2"].Text = "Sample text";
            
            //Set RichText
            IRichTextString richText = worksheet["C2"].RichText;
            
            //Get font
            IFont font = richText.GetFont(1);
            
            //Get font name
            Console.Write(font.FontName);
            
            //Save and Dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
//Output will be
//Calibri
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also