UmyaSpreadsheet.CsvWriterOption (umya_spreadsheet_ex v0.7.0)

View Source

Represents configuration options for CSV export.

This module provides a way to configure options for CSV export, including:

  • Encoding format (UTF-8, ShiftJIS, etc.)
  • Trimming options for cell values
  • Character wrapping for cell values
  • Delimiter character for separating values

Summary

Functions

Converts an Elixir encoding atom to the Rust encoding value.

Creates a new CSV writer option struct with default values.

Sets the CSV encoding value.

Sets the delimiter character used to separate fields in the CSV file. Default is comma (",").

Sets whether to trim whitespace from cell values.

Sets the character to wrap cell values with.

Types

t()

@type t() :: %UmyaSpreadsheet.CsvWriterOption{
  csv_encode_value: atom(),
  delimiter: String.t(),
  do_trim: boolean(),
  wrap_with_char: String.t()
}

Functions

encode_value_to_string(atom)

Converts an Elixir encoding atom to the Rust encoding value.

This function is for internal use to convert our friendly atom names to the exact encoding names used in the Rust library.

new()

Creates a new CSV writer option struct with default values.

Examples

iex> UmyaSpreadsheet.CsvWriterOption.new()
%UmyaSpreadsheet.CsvWriterOption{
  csv_encode_value: :utf8,
  do_trim: false,
  wrap_with_char: "",
  delimiter: ","
}

set_csv_encode_value(options, encode_value)

Sets the CSV encoding value.

Available encodings:

  • :utf8 - UTF-8 encoding (default)
  • :shift_jis - Shift JIS encoding
  • :koi8u - KOI8-U encoding
  • :koi8r - KOI8-R encoding
  • :iso88598i - ISO-8859-8-I encoding
  • :gbk - GBK encoding

Examples

iex> opts = UmyaSpreadsheet.CsvWriterOption.new()
iex> UmyaSpreadsheet.CsvWriterOption.set_csv_encode_value(opts, :shift_jis)
%UmyaSpreadsheet.CsvWriterOption{csv_encode_value: :shift_jis, do_trim: false, wrap_with_char: ""}

set_delimiter(options, delimiter)

Sets the delimiter character used to separate fields in the CSV file. Default is comma (",").

Examples

iex> opts = UmyaSpreadsheet.CsvWriterOption.new()
iex> UmyaSpreadsheet.CsvWriterOption.set_delimiter(opts, ";")
%UmyaSpreadsheet.CsvWriterOption{csv_encode_value: :utf8, do_trim: false, wrap_with_char: "", delimiter: ";"}

set_do_trim(options, do_trim)

Sets whether to trim whitespace from cell values.

Examples

iex> opts = UmyaSpreadsheet.CsvWriterOption.new()
iex> UmyaSpreadsheet.CsvWriterOption.set_do_trim(opts, true)
%UmyaSpreadsheet.CsvWriterOption{csv_encode_value: :utf8, do_trim: true, wrap_with_char: ""}

set_wrap_with_char(options, wrap_with_char)

Sets the character to wrap cell values with.

Examples

iex> opts = UmyaSpreadsheet.CsvWriterOption.new()
iex> UmyaSpreadsheet.CsvWriterOption.set_wrap_with_char(opts, """)
%UmyaSpreadsheet.CsvWriterOption{csv_encode_value: :utf8, do_trim: false, wrap_with_char: "\"", delimiter: ","}