Other API Samples

Live SpreadsheetGear API Samples

Workbook Styles Create Style

Create a custom style when you have a common cell format that could be applied to many cells in a workbook.

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

// Create a new Style and call it "My Style".
SpreadsheetGear.IStyle style = workbook.Styles.Add("Inverted");
style.Font.Color = SpreadsheetGear.Colors.White;
style.Interior.Color = SpreadsheetGear.Colors.Black;

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

// Apply custom style to A6:A10
cells["A6:A10"].Style = style;
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
Workbook > Styles