Other API Samples

Live SpreadsheetGear API Samples

Worksheet Samples Sheet Tab Colors

Modify various attributes relating to sheet tabs.

// Create a new workbook with 3 worksheets.
SpreadsheetGear.IWorkbookSet workbookSet = SpreadsheetGear.Factory.GetWorkbookSet();
workbookSet.SheetsInNewWorkbook = 4;
SpreadsheetGear.IWorkbook workbook = workbookSet.Workbooks.Add();
workbook.Sheets["Sheet4"].Select();

// Set tab color with pre-defined color.
SpreadsheetGear.ITab sheet1Tab = workbook.Sheets["Sheet1"].Tab;
sheet1Tab.Color = SpreadsheetGear.Colors.Red;

// Use arbitrary RGB color.
SpreadsheetGear.ITab sheet2Tab = workbook.Sheets["Sheet2"].Tab;
sheet2Tab.Color = SpreadsheetGear.Color.FromArgb(0, 192, 0);

// Use a theme color
SpreadsheetGear.ITab sheet3Tab = workbook.Sheets["Sheet3"].Tab;
sheet3Tab.ThemeColor = SpreadsheetGear.Themes.ColorSchemeIndex.Accent1;
sheet3Tab.TintAndShade = -0.25; // Make theme color 25% darker.
Run This Sample
Download File

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