Table of Contents

Class WorksheetColorExtensions

Namespace
Openize.Cells
Assembly
Openize.OpenXMLSDK.dll

Provides extension methods for managing worksheet tab colors in Excel workbooks.

public static class WorksheetColorExtensions
Inheritance
WorksheetColorExtensions
Inherited Members

Methods

GetTabColor(Worksheet, out byte, out byte, out byte)

Gets the tab color of a worksheet as RGB values.

public static bool GetTabColor(this Worksheet worksheet, out byte red, out byte green, out byte blue)

Parameters

worksheet Worksheet

The worksheet to get the tab color from.

red byte

Output parameter to receive the red component.

green byte

Output parameter to receive the green component.

blue byte

Output parameter to receive the blue component.

Returns

bool

True if a tab color is set; otherwise, false.

Exceptions

ArgumentNullException

Thrown when worksheet is null.

GetTabColorAsHex(Worksheet)

Gets the tab color of a worksheet as a hex color code.

public static string GetTabColorAsHex(this Worksheet worksheet)

Parameters

worksheet Worksheet

The worksheet to get the tab color from.

Returns

string

The tab color as a hex color code, or null if no tab color is set.

Exceptions

ArgumentNullException

Thrown when worksheet is null.

RemoveTabColor(Worksheet)

Removes the tab color from a worksheet.

public static void RemoveTabColor(this Worksheet worksheet)

Parameters

worksheet Worksheet

The worksheet to remove the tab color from.

Exceptions

ArgumentNullException

Thrown when worksheet is null.

SetTabColor(Worksheet, byte, byte, byte)

Sets the tab color for a worksheet using RGB values.

public static void SetTabColor(this Worksheet worksheet, byte red, byte green, byte blue)

Parameters

worksheet Worksheet

The worksheet to set the tab color for.

red byte

The red component (0-255).

green byte

The green component (0-255).

blue byte

The blue component (0-255).

Exceptions

ArgumentNullException

Thrown when worksheet is null.

ArgumentOutOfRangeException

Thrown when color components are outside the valid range.

SetTabColorByHex(Worksheet, string)

Sets the tab color for a worksheet using an HTML-style hex color code.

public static void SetTabColorByHex(this Worksheet worksheet, string hexColor)

Parameters

worksheet Worksheet

The worksheet to set the tab color for.

hexColor string

The hex color code (e.g., "FF0000" for red).

Exceptions

ArgumentNullException

Thrown when worksheet is null.

ArgumentException

Thrown when hexColor is null, empty, or invalid.