Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IFont Interface : GenerateNativeFont Method

GenerateNativeFont Method (IFont)

Generates .Net font object corresponding to the current font.
Syntax
'Declaration
 
Function GenerateNativeFont() As Font
'Usage
 
Dim instance As IFont
Dim value As Font
 
value = instance.GenerateNativeFont()
Font GenerateNativeFont()

Return Value

Generated .Net font.
Example
The following code illustrates how .Net font object can be generated using GenerateNativeFont() method.
using Syncfusion.XlsIO;
using System;
using System.Drawing;
            
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];
            
            //Set text
            worksheet["C2"].Text = "Sample";
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set font
            IFont font = style.Font;
            
            //Set color
            font.Color = ExcelKnownColors.Red;
            
            //Generate font
            Font nativeFont = font.GenerateNativeFont();
            
            //Get native font name
            Console.Write(nativeFont.Name);
            
            //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