package SZXX

  1. Overview
  2. Docs
type location = {
  1. sheet_number : int;
  2. row_number : int;
  3. col_index : int;
}
val sexp_of_location : location -> Sexplib0.Sexp.t
type 'a cell_parser = {
  1. string : location -> string -> 'a;
  2. formula : location -> formula:string -> string -> 'a;
  3. error : location -> string -> 'a;
  4. boolean : location -> string -> 'a;
  5. number : location -> string -> 'a;
  6. date : location -> string -> 'a;
  7. null : 'a;
}
type delayed_string = {
  1. location : location;
  2. sst_index : string;
}
val sexp_of_delayed_string : delayed_string -> Sexplib0.Sexp.t
type 'a status =
  1. | Available of 'a
  2. | Delayed of delayed_string
val sexp_of_status : ('a -> Sexplib0.Sexp.t) -> 'a status -> Sexplib0.Sexp.t
type 'a row = {
  1. sheet_number : int;
  2. row_number : int;
  3. data : 'a array;
}
val sexp_of_row : ('a -> Sexplib0.Sexp.t) -> 'a row -> Sexplib0.Sexp.t
module SST : sig ... end
val stream_rows : ?only_sheet:int -> ?skip_sst:bool -> feed:Zip.feed -> 'a cell_parser -> 'a status row Lwt_stream.t * SST.t Lwt.t * unit Lwt.t

Returns an Lwt_stream.t of fully parsed XLSX rows, with one caveat: every cell value is wrapped in 'a status. The status can be either Available of 'a or Delayed of delayed_string.

This function will not wait on delayed string cells (see README).

Returns stream * sst_promise * success_promise.

Await success_promise before awaiting the completion of any promise resulting from the stream.

See README.md for examples.

val stream_rows_buffer : ?only_sheet:int -> feed:Zip.feed -> 'a cell_parser -> 'a row Lwt_stream.t * unit Lwt.t

Same as stream_rows but automatically resolves string references. Warning: This function can result in linear (as opposed to constant) memory usage. See README for more information.

val stream_rows_unparsed : ?only_sheet:int -> ?skip_sst:bool -> feed:Zip.feed -> unit -> Xml.DOM.element row Lwt_stream.t * SST.t Lwt.t * unit Lwt.t

Same as stream_rows but returns raw XML elements instead of parsed XLSX rows. This function can be useful to filter out uninteresting rows at a lower cost.

val yojson_cell_parser : [> `Bool of bool | `Float of float | `String of string | `Null ] cell_parser

Convenience cell_parser to read rows as JSON (Yojson)

val parse_row_with_sst : SST.t -> 'a cell_parser -> Xml.DOM.element row -> 'a row

Convert an XML element as returned by stream_rows_unparsed into a nicer 'a row as returned by stream_rows_buffer

val parse_row_without_sst : 'a cell_parser -> Xml.DOM.element row -> 'a status row

Convert an XML element as returned by stream_rows_unparsed into a nicer 'a status row as returned by stream_rows

val unwrap_status : 'a cell_parser -> SST.t -> 'a status row -> 'a row

Unwrap a single row, resolving all SST references.

A common workflow is to call Lwt_stream.filter on the stream returned by stream_rows, discarding uninteresting rows in order to buffer as few rows as possible, then await the sst Lwt.t, and finally consume the stream, calling unwrap_status on each row to get the String data.

val resolve_sst_index : SST.t -> sst_index:string -> string option

Resolve a single reference into the Shared Strings Table.

val parse_date : float -> Core.Date.t

XLSX dates are stored as floats. Convert from a float to a Date.t

val parse_datetime : zone:Core.Time.Zone.t -> float -> Core.Time.t

XLSX datetimes are stored as floats. Convert from a float to a Time.t

val index_of_column : string -> int

Convert from a column reference such as "D7" or "AA2" to a 0-based column index