Other API Samples

Live SpreadsheetGear API Samples

Range Samples Formatting and Other Cell Features Font

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

// 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();
Run This Sample
Render Image

Generate an image representation of the results of this sample, which uses the SpreadsheetGear.Drawing.Image class to convert ranges, charts and shapes to images.


Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.

Related Samples