Other API Samples C# logo

Modify Style SpreadsheetGear API Sample

Description

This sample will modify the "Normal" style, which is the default style used by all cells in a workbook. Modifying this style will typically modify all cells in the workbook, unless you have setup cells to use other styles.

Sample Source Code

// Create a new workbook.
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets["Sheet1"];
SpreadsheetGear.IRange cells = worksheet.Cells;

// Get the "Normal" style for this workbook and modify it.
SpreadsheetGear.IStyle style = workbook.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Interior.Color = SpreadsheetGear.Colors.Yellow;

// Add some cell data to cell A1.
cells["B2"].Value = "Hello World!";