UmyaSpreadsheet.FontFunctions (umya_spreadsheet_ex v0.7.0)

View Source

Functions for manipulating font styles in a spreadsheet.

Summary

Functions

Gets the italic state for a cell.

Gets the strikethrough state for a cell.

Gets the underline style for a cell.

Sets the font weight (bold) for a cell.

Sets the font style to italic for a cell.

Functions

get_font_bold(spreadsheet, sheet_name, cell_address)

Gets the bold state for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, is_bold} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, is_bold} = UmyaSpreadsheet.FontFunctions.get_font_bold(spreadsheet, "Sheet1", "A1")

get_font_color(spreadsheet, sheet_name, cell_address)

Gets the font color for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, font_color} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, font_color} = UmyaSpreadsheet.FontFunctions.get_font_color(spreadsheet, "Sheet1", "A1")

get_font_family(spreadsheet, sheet_name, cell_address)

Gets the font family for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, font_family} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, font_family} = UmyaSpreadsheet.FontFunctions.get_font_family(spreadsheet, "Sheet1", "A1")

get_font_italic(spreadsheet, sheet_name, cell_address)

Gets the italic state for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, is_italic} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, is_italic} = UmyaSpreadsheet.FontFunctions.get_font_italic(spreadsheet, "Sheet1", "A1")

get_font_name(spreadsheet, sheet_name, cell_address)

Gets the font name for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, font_name} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, font_name} = UmyaSpreadsheet.FontFunctions.get_font_name(spreadsheet, "Sheet1", "A1")

get_font_scheme(spreadsheet, sheet_name, cell_address)

Gets the font scheme for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, font_scheme} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, font_scheme} = UmyaSpreadsheet.FontFunctions.get_font_scheme(spreadsheet, "Sheet1", "A1")

get_font_size(spreadsheet, sheet_name, cell_address)

Gets the font size for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, font_size} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, font_size} = UmyaSpreadsheet.FontFunctions.get_font_size(spreadsheet, "Sheet1", "A1")

get_font_strikethrough(spreadsheet, sheet_name, cell_address)

Gets the strikethrough state for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, is_strikethrough} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, is_strikethrough} = UmyaSpreadsheet.FontFunctions.get_font_strikethrough(spreadsheet, "Sheet1", "A1")

get_font_underline(spreadsheet, sheet_name, cell_address)

Gets the underline style for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")

Returns

  • {:ok, underline_style} on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, underline_style} = UmyaSpreadsheet.FontFunctions.get_font_underline(spreadsheet, "Sheet1", "A1")

set_font_bold(spreadsheet, sheet_name, cell_address, is_bold)

Sets the font weight (bold) for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • is_bold - Boolean indicating whether the font should be bold

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_bold(spreadsheet, "Sheet1", "A1", true)

set_font_color(spreadsheet, sheet_name, cell_address, color)

Sets the font color for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_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 text to red
:ok = UmyaSpreadsheet.FontFunctions.set_font_color(spreadsheet, "Sheet1", "A1", "#FF0000")

set_font_family(spreadsheet, sheet_name, cell_address, font_family)

Sets the font family for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • font_family - The font family: "roman" (serif), "swiss" (sans-serif), "modern" (monospace), "script", or "decorative"

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_family(spreadsheet, "Sheet1", "A1", "swiss")

set_font_italic(spreadsheet, sheet_name, cell_address, is_italic)

Sets the font style to italic for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • is_italic - Boolean indicating whether the font should be italic

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_italic(spreadsheet, "Sheet1", "A1", true)

set_font_name(spreadsheet, sheet_name, cell_address, font_name)

Sets the font name for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • font_name - The name of the font

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_name(spreadsheet, "Sheet1", "A1", "Arial")

set_font_scheme(spreadsheet, sheet_name, cell_address, font_scheme)

Sets the font scheme for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • font_scheme - The font scheme: "major", "minor", or "none"

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_scheme(spreadsheet, "Sheet1", "A1", "major")

set_font_size(spreadsheet, sheet_name, cell_address, size)

Sets the font size for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • size - The font size in points

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_size(spreadsheet, "Sheet1", "A1", 14)

set_font_strikethrough(spreadsheet, sheet_name, cell_address, is_strikethrough)

Sets the font strikethrough property for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • is_strikethrough - Boolean indicating whether the font should have strikethrough

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_strikethrough(spreadsheet, "Sheet1", "A1", true)

set_font_underline(spreadsheet, sheet_name, cell_address, underline_style)

Sets the font underline style for a cell.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet
  • cell_address - The cell address (e.g., "A1", "B5")
  • underline_style - The underline style ("single", "double", "none")

Returns

  • :ok on success
  • {:error, reason} on failure

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.FontFunctions.set_font_underline(spreadsheet, "Sheet1", "A1", "single")