Class WorksheetColorExtensions
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
worksheetWorksheetThe worksheet to get the tab color from.
redbyteOutput parameter to receive the red component.
greenbyteOutput parameter to receive the green component.
bluebyteOutput 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
worksheetWorksheetThe 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
worksheetWorksheetThe 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
worksheetWorksheetThe worksheet to set the tab color for.
redbyteThe red component (0-255).
greenbyteThe green component (0-255).
bluebyteThe 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
worksheetWorksheetThe worksheet to set the tab color for.
hexColorstringThe hex color code (e.g., "FF0000" for red).
Exceptions
- ArgumentNullException
Thrown when worksheet is null.
- ArgumentException
Thrown when hexColor is null, empty, or invalid.