SpreadsheetGear 2023
IFont Interface
Members  Example 


SpreadsheetGear Namespace : IFont Interface
Represents the font of a cell, range or object. Setting the properties of an instance of IFont modifies the font properties of the represented cell, range or object.
Object Model
IFont Interface
Syntax
'Declaration
 
Public Interface IFont 
'Usage
 
Dim instance As IFont
public interface IFont 
Example
class Program
{
    static void Main()
    {
        // Create a workbook.
        SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
        // Get the worksheet and change the name.
        SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
        worksheet.Name = "2005 Sales";
        // Get the worksheet cells reference.
        SpreadsheetGear.IRange cells = worksheet.Cells;
        // Add column headers.
        cells["B1"].Formula = "Jan";
        cells["C1"].Formula = "Feb";
        cells["D1"].Formula = "Mar";
        // Add row headers.
        cells["A2"].Formula = "Jennifer";
        cells["A3"].Formula = "William";
        cells["A4"].Formula = "Kristen";
        // Add random data.
        cells["B2:D4"].Formula = "=RAND()*10000";
        // Center the column headers.
        cells["B1:D1"].HorizontalAlignment = SpreadsheetGear.HAlign.Center;
        // Bold the row and column headers.
        cells["B1:D1,A2:A4"].Font.Bold = true;
        // Format the data as currency.
        cells["B2:D4"].NumberFormat = "$#,##0";
        // Write the workbook.
        workbook.SaveAs("2005 Sales.xls", SpreadsheetGear.FileFormat.Excel8);
    }
}
Class Program
{
    Static void Main()
    {
        // Create a workbook.
        SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
        // Get the worksheet And change the name.
        SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
        worksheet.Name = "2005 Sales";
        // Get the worksheet cells reference.
        SpreadsheetGear.IRange cells = worksheet.Cells;
        // Add column headers.
        cells["B1"].Formula = "Jan";
        cells["C1"].Formula = "Feb";
        cells["D1"].Formula = "Mar";
        // Add row headers.
        cells["A2"].Formula = "Jennifer";
        cells["A3"].Formula = "William";
        cells["A4"].Formula = "Kristen";
        // Add random Data.
        cells["B2:D4"].Formula = "=RAND()*10000";
        // Center the column headers.
        cells["B1:D1"].HorizontalAlignment = SpreadsheetGear.HAlign.Center;
        // Bold the row And column headers.
        cells["B1:D1,A2:A4"].Font.Bold = True;
        // Format the Data As Currency.
        cells["B2:D4"].NumberFormat = "$#,##0";
        // Write the workbook.
        workbook.SaveAs("2005 Sales.xls", SpreadsheetGear.FileFormat.Excel8);
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IFont Members
SpreadsheetGear Namespace