UmyaSpreadsheet.CsvWriterOption (umya_spreadsheet_ex v0.7.0)
View SourceRepresents 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
Functions
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.
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: ","
}
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: ""}
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: ";"}
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: ""}
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: ","}