UmyaSpreadsheet.CSVFunctions (umya_spreadsheet_ex v0.7.0)

View Source

Functions for exporting spreadsheets to CSV format.

Summary

Functions

Exports a sheet to CSV format with default options.

Exports a sheet to CSV format with custom options.

Exports a sheet to CSV format with custom options.

Functions

write_csv(spreadsheet, sheet_name, path)

Exports a sheet to CSV format with default options.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet to export
  • path - The output path for the CSV file

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.CSVFunctions.write_csv(spreadsheet, "Sheet1", "output.csv")

write_csv(spreadsheet, sheet_name, path, options)

Exports a sheet to CSV format with custom options.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet to export
  • path - The output path for the CSV file
  • options - A map of CSV writer options with the following fields:
    • :encoding - The character encoding to use (default: "UTF8")
    • :delimiter - The field delimiter (default: ",")
    • :do_trim - Whether to trim whitespace (default: false)
    • :wrap_with_char - Character to wrap fields with (default: "")

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")

options = %{
  encoding: "UTF8",
  delimiter: ";",
  do_trim: true,
  wrap_with_char: """
}

:ok = UmyaSpreadsheet.CSVFunctions.write_csv(spreadsheet, "Sheet1", "output.csv", options)

write_csv_with_options(spreadsheet, sheet_name, path, options)

Exports a sheet to CSV format with custom options.

Parameters

  • spreadsheet - The spreadsheet struct
  • sheet_name - The name of the sheet to export
  • path - The output path for the CSV file
  • options - A map of CSV writer options with the following fields:
    • :encoding - The character encoding to use (default: "UTF8")
    • :delimiter - The field delimiter (default: ",")
    • :do_trim - Whether to trim whitespace (default: false)
    • :wrap_with_char - Character to wrap fields with (default: "")

Examples

{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")

options = %{
  encoding: "UTF8",
  delimiter: ";",
  do_trim: true,
  wrap_with_char: """
}

:ok = UmyaSpreadsheet.CSVFunctions.write_csv_with_options(spreadsheet, "Sheet1", "output.csv", options)