Other API Samples C# logo

Font SpreadsheetGear API Sample

Description

Set various font options such as Font Name, Bold and Color.

Sample Source Code

// Create a new workbook and some local variables.
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.ActiveWorksheet;
SpreadsheetGear.IRange cells = worksheet.Cells;

// Get a reference to cell B2.
SpreadsheetGear.IRange cell = cells["B2"];

// Add text to the cell.
cell.Value = "SpreadsheetGear Engine for .NET";

// Get a reference to the range's font.
SpreadsheetGear.IFont font = cell.Font;

// Set various font options.
font.Name = "Times New Roman";
font.Size = 14;
font.Bold = true;
font.Color = SpreadsheetGear.Colors.Blue;

// AutoFit the column.
cell.EntireColumn.AutoFit();