UmyaSpreadsheet.BackgroundFunctions (umya_spreadsheet_ex v0.7.0)
View SourceFunctions for manipulating and inspecting cell background colors in a spreadsheet.
Summary
Functions
Gets the background color of a cell.
Gets the foreground color of a cell.
Gets the pattern type of a cell's fill.
Sets the background color of a cell.
Functions
Gets the background color of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, color}
on success where color is a hex color code (e.g., "FFFFFF00"){:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, color} = UmyaSpreadsheet.BackgroundFunctions.get_cell_background_color(spreadsheet, "Sheet1", "A1")
# => "FFFFFF00" (yellow background)
Gets the foreground color of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, color}
on success where color is a hex color code (e.g., "FFFFFFFF"){:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, color} = UmyaSpreadsheet.BackgroundFunctions.get_cell_foreground_color(spreadsheet, "Sheet1", "A1")
# => "FFFFFFFF" (white foreground)
Gets the pattern type of a cell's fill.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, pattern_type}
on success where pattern_type is a string (e.g., "solid", "none"){:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, pattern} = UmyaSpreadsheet.BackgroundFunctions.get_cell_pattern_type(spreadsheet, "Sheet1", "A1")
# => "solid"
Sets the background color of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")color
- The color code (e.g., "#FF0000" for red)
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Set cell background to light blue
:ok = UmyaSpreadsheet.BackgroundFunctions.set_background_color(spreadsheet, "Sheet1", "A1", "#CCECFF")