← all modules

Std.Office.Xlsx

Std.Office.Xlsx
  Std.Office.Xlsx — read and write Excel workbooks (.xlsx).

Types
  type Cell = Empty | Text String | Number Float | Boolean Bool | Date DateTime | Formula String Cell | Failure String
  type alias DateTime = { year : Int , month : Int , day : Int , hour : Int , minute : Int , second : Int , millisecond : Int }
  type Visibility = Visible | Hidden | VeryHidden
  type alias Range = { firstRow : Int , firstColumn : Int , lastRow : Int , lastColumn : Int }
  type Validation = ListOf Range (List String) | ListFromRange Range String
  type alias Sheet = { name : String , visibility : Visibility , rows : List (List Cell) , merged : List Range , columnWidths : List ( Int, Float ) , frozen : Maybe { rows : Int, columns : Int } , validations : List Validation }
  type alias Workbook = { sheets : List Sheet , date1904 : Bool }
  type alias Limits = { zip : Zip.Limits , maxSheets : Int , maxRows : Int , maxCells : Int , maxColumns : Int }
  type CellSpec
  type alias SheetSpec = { name : String , visibility : Visibility , rows : List (List CellSpec) , columnWidths : List ( Int, Float ) , frozen : Maybe { rows : Int, columns : Int } , merged : List Range , validations : List Validation }
  type alias WCell = { kind : Int , text : String , number : Float , flag : Bool , parts : List Int , bold : Bool , italic : Bool , size : Int , fill : Int , format : String , wrap : Bool }
  type alias RawWidth = { column : Int , width : Float }
  type alias RawValidation = { kind : Int , range : Range , items : List String , source : String }
  type alias WSheet = { name : String , visibility : Int , rows : List (List WCell) , columnWidths : List RawWidth , frozenRows : Int , frozenColumns : Int , merged : List Range , validations : List RawValidation }
  type RawCell
  type alias RawSheet = { name : String , visibility : Int , rows : List (List RawCell) , merged : List Range , columnWidths : List RawWidth , frozenRows : Int , frozenColumns : Int , validations : List RawValidation }
  type alias RawWorkbook = { sheets : List RawSheet , date1904 : Bool }

Values
  bold : CellSpec -> CellSpec
      Bold text.
  bool : Bool -> CellSpec
      A TRUE / FALSE cell.
  date : DateTime -> CellSpec
      A date cell, written as a serial number with the format `yyyy-mm-dd`
  defaultLimits : Limits
      `Zip.defaultLimits`, 100 sheets, 200,000 rows, 2,000,000 cells, 16,384
  empty : CellSpec
      An empty cell. In a row it keeps the cells after it in their columns.
  failure : String -> CellSpec
      An error value cell, such as `failure "#N/A"`.
  fill : Int -> Int -> Int -> CellSpec -> CellSpec
      A solid background colour: red, green and blue from 0 to 255.
  fontSize : Int -> CellSpec -> CellSpec
      The font size in points (11 by default).
  formula : String -> CellSpec
      A formula cell, such as `formula "SUM(B2:B9)"` (a leading `=` is
  fromCell : Cell -> CellSpec
      The cell to write for a cell read, unstyled. A `Formula` keeps its text,
  int : Int -> CellSpec
      A whole-number cell.
  italic : CellSpec -> CellSpec
      Italic text.
  number : Float -> CellSpec
      A number cell.
  numberFormat : String -> CellSpec -> CellSpec
      An Excel number format, such as `"#,##0.00"`, `"0.0%"` or
  read : String -> Result Error Workbook
      Every sheet of a workbook, under `defaultLimits`.
  readWith : Limits -> String -> Result Error Workbook
      `read` with chosen limits.
  sheet : String -> List (List CellSpec) -> SheetSpec
      A visible sheet with these rows and nothing else set. Change the rest
  sheetNames : String -> Result Error (List { name : String, visibility : Visibility })
      The sheet names and their visibility, in tab order, read from the
  text : String -> CellSpec
      A text cell (at most 32,767 characters).
  wrap : CellSpec -> CellSpec
      Wrap long text inside the cell.
  write : List SheetSpec -> Result Error String
      The workbook of these sheets, in tab order. The first visible sheet is