Skip to content

Simple OCaml library to export .xlsx files as CSVs

License

Notifications You must be signed in to change notification settings

zazedd/xlsx2csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 10, 2024
b4b4ed8 · Oct 10, 2024

History

7 Commits
Oct 10, 2024
Sep 2, 2024
Sep 2, 2024
Oct 10, 2024
Sep 2, 2024
Oct 10, 2024
Oct 10, 2024

Repository files navigation

xlsx2csv

Simple library to export .xlsx files as CSVs

Basic usage

File into a list of strings:

let csvs = Xlsx2csv.convert ~into:`Strings "/path/to/your/excel_file.xlsx" in
match csvs with
| Ok (`Strings lst) ->
    List.iteri
      (fun i r ->
        let d = Format.dprintf "Sheet %d" (i + 1) in
        match r with
        | Ok str -> Format.printf "%t:@.%s@.@." d str
        | Error (`Msg msg) -> Format.printf "ERROR %t:@.%s@.@." d msg)
      lst
| Error (`Msg msg) -> failwith msg
| _ -> assert false

File into more files:

let files =
  Xlsx2csv.convert
    ~enc:(Some `UTF_16)
    ~ignore_hiddens:true
    ~into:(`Files ("/path/to/output/folder", "file_name"))
    "/path/to/your/excel_file.xlsx"
in
match files with
| Ok (`Files lst) ->
    List.iteri
      (fun i r ->
        let d = Format.dprintf "Sheet %d" (i + 1) in
        match r with
        | Ok () -> Format.printf "%t:@.OK@.@." d
        | Error (`Msg msg) -> Format.printf "ERROR %t:@.%s@.@." d msg)
      lst
| Error (`Msg msg) -> failwith msg
| _ -> assert false

About

Simple OCaml library to export .xlsx files as CSVs

Resources

License

Stars

Watchers

Forks

Packages

No packages published