UmyaSpreadsheet.CommentFunctions (umya_spreadsheet_ex v0.7.0)

View Source

Functions for working with cell comments in spreadsheets.

Summary

Functions

Gets the comment text and author from a cell.

Gets the number of comments in a sheet.

Checks if a sheet has any comments.

Functions

add_comment(spreadsheet, sheet_name, cell_address, text, author)

@spec add_comment(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  :ok | {:error, atom()}

Adds a comment to a cell.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet
  • cell_address - Cell address in A1 notation (e.g., "A1", "B2")
  • text - Text content of the comment
  • author - Name of the comment author

Examples

iex> UmyaSpreadsheet.add_comment(spreadsheet, "Sheet1", "A1", "This is a comment", "John Doe")
:ok

get_comment(spreadsheet, sheet_name, cell_address)

@spec get_comment(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  {:ok, String.t(), String.t()} | {:error, atom()}

Gets the comment text and author from a cell.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet
  • cell_address - Cell address in A1 notation (e.g., "A1", "B2")

Examples

iex> UmyaSpreadsheet.get_comment(spreadsheet, "Sheet1", "A1")
{:ok, "This is a comment", "John Doe"}

get_comments_count(spreadsheet, sheet_name)

@spec get_comments_count(UmyaSpreadsheet.Spreadsheet.t(), String.t()) ::
  integer() | {:error, atom()}

Gets the number of comments in a sheet.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet

Examples

iex> UmyaSpreadsheet.get_comments_count(spreadsheet, "Sheet1")
3

has_comments(spreadsheet, sheet_name)

@spec has_comments(UmyaSpreadsheet.Spreadsheet.t(), String.t()) ::
  boolean() | {:error, atom()}

Checks if a sheet has any comments.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet

Examples

iex> UmyaSpreadsheet.has_comments(spreadsheet, "Sheet1")
true

remove_comment(spreadsheet, sheet_name, cell_address)

@spec remove_comment(UmyaSpreadsheet.Spreadsheet.t(), String.t(), String.t()) ::
  :ok | {:error, atom()}

Removes a comment from a cell.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet
  • cell_address - Cell address in A1 notation (e.g., "A1", "B2")

Examples

iex> UmyaSpreadsheet.remove_comment(spreadsheet, "Sheet1", "A1")
:ok

update_comment(spreadsheet, sheet_name, cell_address, text, author \\ nil)

@spec update_comment(
  UmyaSpreadsheet.Spreadsheet.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t() | nil
) :: :ok | {:error, atom()}

Updates an existing comment in a cell.

Parameters

  • spreadsheet - The spreadsheet reference
  • sheet_name - Name of the worksheet
  • cell_address - Cell address in A1 notation (e.g., "A1", "B2")
  • text - New text content for the comment
  • author - Optional new author name (if nil, keeps the existing author)

Examples

iex> UmyaSpreadsheet.update_comment(spreadsheet, "Sheet1", "A1", "Updated comment")
:ok

iex> UmyaSpreadsheet.update_comment(spreadsheet, "Sheet1", "A1", "Updated comment", "Jane Smith")
:ok