UmyaSpreadsheet.CellFunctions (umya_spreadsheet_ex v0.7.0)
View SourceFunctions for manipulating individual cells in a spreadsheet.
Summary
Functions
Gets the border color of a cell.
Gets the border style of a cell.
Gets the background color of a cell.
Gets the foreground color of a cell.
Gets the number format code of a cell.
Gets the hidden status of a cell.
Gets the horizontal alignment of a cell.
Gets the locked status of a cell.
Gets the number format ID of a cell.
Gets the pattern type of a cell's fill.
Gets the text rotation of a cell.
Gets the value of a cell.
Gets the vertical alignment of a cell.
Gets the wrap text setting of a cell.
Gets the formatted value of a cell (as displayed in Excel).
Removes a cell from the spreadsheet.
Sets the cell alignment.
Sets the text indentation level for a cell.
Sets the text rotation angle for a cell.
Sets the value of a cell.
Sets the number format for a cell.
Sets text wrapping for a cell.
Functions
Gets the border color of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")border_position
- "top", "bottom", "left", "right", or "diagonal"
Returns
{:ok, color}
where color is the border color in hex format (e.g., "#FF0000"){:error, reason}
on failure
Gets the border style of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")border_position
- "top", "bottom", "left", "right", or "diagonal"
Returns
{:ok, style}
where style is the border style (e.g., "solid", "dashed", "dotted"){:error, reason}
on failure
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}
where color is the background color in hex format (e.g., "#FFFFFF"){:error, reason}
on failure
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}
where color is the foreground color in hex format (e.g., "#000000"){:error, reason}
on failure
Gets the number format code of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, format_code}
where format_code is the number format code (e.g., "0.00", "m/d/yyyy"){:error, reason}
on failure
Gets the horizontal alignment of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, alignment}
where alignment is "general", "left", "center", "right", etc.{:error, reason}
on failure
Gets the locked status of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, locked}
where locked is a boolean indicating if the cell is locked{:error, reason}
on failure
Gets the number format ID of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, format_id}
where format_id is the number format ID{:error, reason}
on failure
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}
where pattern_type is the pattern type (e.g., "solid", "none"){:error, reason}
on failure
Gets the text rotation of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, angle}
where angle is the rotation angle in degrees{:error, reason}
on failure
Gets the value of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
- The cell value as a string
{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
"Hello" = UmyaSpreadsheet.CellFunctions.get_cell_value(spreadsheet, "Sheet1", "A1")
Gets the vertical alignment of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, alignment}
where alignment is "top", "center", "bottom", etc.{:error, reason}
on failure
Gets the wrap text setting of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
{:ok, wrap}
where wrap is a boolean indicating if text wrapping is enabled{:error, reason}
on failure
Gets the formatted value of a cell (as displayed in Excel).
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
- The formatted cell value as a string
{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
"12/31/2023" = UmyaSpreadsheet.CellFunctions.get_formatted_value(spreadsheet, "Sheet1", "A1")
Removes a cell from the spreadsheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.remove_cell(spreadsheet, "Sheet1", "A1")
Sets the cell alignment.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")horizontal
- Horizontal alignment ("left", "center", "right", "justify")vertical
- Vertical alignment ("top", "center", "bottom")
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.set_cell_alignment(spreadsheet, "Sheet1", "A1", "center", "center")
Sets the text indentation level for a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")level
- The indentation level
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.set_cell_indent(spreadsheet, "Sheet1", "A1", 2)
Sets the text rotation angle for a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")angle
- The rotation angle in degrees
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.set_cell_rotation(spreadsheet, "Sheet1", "A1", 45)
Sets the value of a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")value
- The value to set
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.set_cell_value(spreadsheet, "Sheet1", "A1", "Hello")
Sets the number format for a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")format_code
- The format code (e.g., "0.00", "m/d/yyyy")
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Set number format to 2 decimal places
:ok = UmyaSpreadsheet.CellFunctions.set_number_format(spreadsheet, "Sheet1", "A1", "0.00")
# Set date format
:ok = UmyaSpreadsheet.CellFunctions.set_number_format(spreadsheet, "Sheet1", "B1", "m/d/yyyy")
Sets text wrapping for a cell.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5")wrap
- Boolean indicating whether to wrap text
Returns
:ok
on success{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CellFunctions.set_wrap_text(spreadsheet, "Sheet1", "A1", true)