Liking cljdoc? Tell your friends :D

dk.ative.docjure.spreadsheet


add-name!clj

(add-name! workbook n string-ref)
source

add-row!clj

(add-row! sheet values)
source

add-rows!clj

(add-rows! sheet rows)

Add rows to the sheet. The rows is a sequence of row-data, where each row-data is a sequence of values for the columns in increasing order on that row.

Add rows to the sheet. The rows is a sequence of row-data, where
each row-data is a sequence of values for the columns in increasing
order on that row.
sourceraw docstring

add-sheet!clj

(add-sheet! workbook name)

Add a new sheet to the workbook.

Add a new sheet to the workbook.
sourceraw docstring

apply-date-format!clj

(apply-date-format! cell format)
source

assert-typecljmacro

(assert-type value expected-type)
source

borderclj

(border kw)

Returns border style

Returns border style
sourceraw docstring

cell-fnclj

(cell-fn outputcell sheet & inputcells)

Turn a cell (ideally containing a formula) into a function. The returned function will take a variable number of parameters, updating each of the inputcells in the sheet with the supplied values and return the value of the cell outputcell. Cell names are specified using Excel syntax, i.e. A2 or B12.

Turn a cell (ideally containing a formula) into a function. The returned function
will take a variable number of parameters, updating each of the inputcells in the
sheet with the supplied values and return the value of the cell outputcell.
Cell names are specified using Excel syntax, i.e. A2 or B12.
sourceraw docstring

cell-referenceclj

(cell-reference cell)
source

cell-seqcljmultimethod

Return a seq of the cells in the input which can be a sheet, a row, or a collection of one of these. The seq is ordered ordered by sheet, row and column. Missing cells will be returned as nil, note this is different from blank cells which have type (CellType/BLANK)

Return a seq of the cells in the input which can be a sheet, a row, or a collection
of one of these. The seq is ordered ordered by sheet, row and column.
Missing cells will be returned as nil, note this is different from blank cells which have type (CellType/BLANK)
sourceraw docstring

color-indexclj

(color-index colorkw)

Returns color index from org.apache.ss.usermodel.IndexedColors from lowercase keywords

Returns color index from org.apache.ss.usermodel.IndexedColors
from lowercase keywords
sourceraw docstring

create-cell-style!clj

(create-cell-style! workbook)
(create-cell-style! workbook styles)

Create a new cell-style in the workbook from options:

:background background colour (as keyword) :font font | fontmap (of font options) :halign :left | :right | :center :valign :top | :bottom | :center :wrap true | false - controls text wrapping :border-left :thin | :medium | :thick :border-right :thin | :medium | :thick :border-top :thin | :medium | :thick :border-bottom :thin | :medium | :thick :left-border-color colour keyword :right-border-color colour keyword :top-border-color colour keyword :bottom-border-color colour keyword :indent number from 0 to 15 :data-format string

Valid colour keywords are the colour names defined in org.apache.ss.usermodel.IndexedColors as lowercase keywords, eg.

:black, :white, :red, :blue, :light_green, :yellow, ...

Examples: I. (def f (create-font! wb {:name "Arial", :bold true, :italic true}) (create-cell-style! wb {:background :yellow, :font f, :halign :center, :wrap true, :border-bottom :thin}) II. (create-cell-style! wb {:background :yellow, :halign :center, :font {:name "Arial" :bold true :italic true}, :wrap true, :border-bottom :thin})

Create a new cell-style in the workbook from options:

   :background          background colour (as keyword)
   :font                font | fontmap (of font options)
   :halign              :left | :right | :center
   :valign              :top | :bottom | :center
   :wrap                true | false - controls text wrapping
   :border-left         :thin | :medium | :thick
   :border-right        :thin | :medium | :thick
   :border-top          :thin | :medium | :thick
   :border-bottom       :thin | :medium | :thick
   :left-border-color   colour keyword
   :right-border-color  colour keyword
   :top-border-color    colour keyword
   :bottom-border-color colour keyword
   :indent              number from 0 to 15
   :data-format         string

Valid colour keywords are the colour names defined in
org.apache.ss.usermodel.IndexedColors as lowercase keywords, eg.

  :black, :white, :red, :blue, :light_green, :yellow, ...

Examples:
I.
(def f (create-font! wb {:name "Arial", :bold true, :italic true})
(create-cell-style! wb {:background :yellow, :font f, :halign :center,
                        :wrap true, :border-bottom :thin})
II.
(create-cell-style! wb {:background :yellow, :halign :center,
                        :font {:name "Arial" :bold true :italic true},
                        :wrap true, :border-bottom :thin})
sourceraw docstring

create-font!clj

(create-font! workbook options)

Create a new font in the workbook with options:

:name      font family (string)
:size      font size  (integer)
:color     font color (keyword)
:bold      true | false
:italic    true | false
:underline true | false

Example:

(create-font! wb {:name "Arial", :size 12, :color :blue, :bold true, :underline true})

Create a new font in the workbook with options:

    :name      font family (string)
    :size      font size  (integer)
    :color     font color (keyword)
    :bold      true | false
    :italic    true | false
    :underline true | false

Example:

   (create-font! wb
    {:name "Arial", :size 12, :color :blue,
     :bold true, :underline true})
sourceraw docstring

create-sparse-workbookclj

(create-sparse-workbook sheet-name data)
(create-sparse-workbook sheet-name data & name-data-pairs)

Create a new XLSX workbook. Sheet-name is a string name for the sheet. Data is a vector of vectors, representing the rows and the cells of the rows. Alternate sheet names and data to create multiple sheets.

Spreadsheet rows and cells can be nil, which will create a sparse spreadsheet with non-continuous rows and cells

(This version exists mostly for generating test data, create-workbook will normally do just fine unless you have a specific need for sparseness)

(create-sparse-workbook "SheetName1" [["A1" "A2"] nil ["C1" nil "C3"]] "SheetName2" [["A1" "A2"] nil ["C1" nil "C3"]]

Create a new XLSX workbook.  Sheet-name is a string name for the sheet. Data
is a vector of vectors, representing the rows and the cells of the rows.
Alternate sheet names and data to create multiple sheets.

Spreadsheet rows and cells can be nil, which will create a sparse spreadsheet with
non-continuous rows and cells

(This version exists mostly for generating test data, `create-workbook` will
normally do just fine unless you have a specific need for sparseness)

(create-sparse-workbook "SheetName1" [["A1" "A2"] nil ["C1" nil "C3"]]
                        "SheetName2" [["A1" "A2"] nil ["C1" nil "C3"]] 
sourceraw docstring

create-workbookclj

(create-workbook sheet-name data)
(create-workbook sheet-name data & name-data-pairs)

Create a new XLSX workbook. Sheet-name is a string name for the sheet. Data is a vector of vectors, representing the rows and the cells of the rows. Alternate sheet names and data to create multiple sheets.

(create-workbook "SheetName1" [["A1" "A2"]["B1" "B2"]] "SheetName2" [["A1" "A2"]["B1" "B2"]]

Create a new XLSX workbook.  Sheet-name is a string name for the sheet. Data
is a vector of vectors, representing the rows and the cells of the rows.
Alternate sheet names and data to create multiple sheets.

(create-workbook "SheetName1" [["A1" "A2"]["B1" "B2"]]
                 "SheetName2" [["A1" "A2"]["B1" "B2"]] 
sourceraw docstring

create-xls-workbookclj

(create-xls-workbook sheet-name data)

Create a new XLS workbook with a single sheet and the data specified.

Create a new XLS workbook with a single sheet and the data specified.
sourceraw docstring

escape-cellclj

(escape-cell value)

When inputting a cell's value in an xlsx workbook, Excel allows 16-bit unicode characters to be input in an escaped form matching this regular expression: x[0-9A-F]{4}.

For example, the character 'A' can be input as 'x0041', the lowercase greek character pi can be input as 'x03C0'.

If your data contains cell values that match this form that you do not want to be interpreted as 16-bit unicode values, the string '_x005F' needs to be prepended to each occurance. For example, to stop 'x03C0' from being interpreted as the character pi you must input 'x005F_x03C0'.

This function will escape all occurances of the Excel 16-bit unicode escape sequence in the specified cell value.

(escape-cell "foo x0041 bar x03C0") => "foo x005F_x0041 bar x005F_x03C0"

When inputting a cell's value in an xlsx workbook, Excel allows 16-bit
unicode characters to be input in an escaped form matching this regular
expression: _x[0-9A-F]{4}_.

For example, the character 'A' can be input as '_x0041_', the
lowercase greek character pi can be input as '_x03C0_'.

If your data contains cell values that match this form that you do not
want to be interpreted as 16-bit unicode values, the string '_x005F'
needs to be prepended to each occurance. For example, to stop
'_x03C0_' from being interpreted as the character pi you must input
'_x005F_x03C0_'.

This function will escape all occurances of the Excel 16-bit unicode
escape sequence in the specified cell value.

(escape-cell "foo _x0041_ bar _x03C0_")
=> "foo _x005F_x0041_ bar _x005F_x03C0_"
sourceraw docstring

get-row-stylesclj

(get-row-styles row)

Returns a seq of the row's CellStyles. Missing cells will return a nil style

Returns a seq of the row's CellStyles.
Missing cells will return a nil style
sourceraw docstring

horiz-alignclj

(horiz-align kw)

Returns horizontal alignment

Returns horizontal alignment
sourceraw docstring

IFontablecljprotocol

A protocol that allows:

  1. interchangeable use of fonts and maps of font options
  2. getting fonts from either XLS or XLSX cell styles, which normally requires distinct syntax.
A protocol that allows:
1. interchangeable use of fonts and maps of font options
2. getting fonts from either XLS or XLSX cell styles, which
   normally requires distinct syntax.

as-fontclj

(as-font this workbook)

get-fontclj

(get-font this workbook)

set-fontclj

(set-font this style workbook)
sourceraw docstring

into-seqclj

(into-seq sheet-or-row)
source

load-workbookcljmultimethod

Load an Excel .xls or .xlsx workbook from an InputStream.

Load an Excel .xls or .xlsx workbook from an InputStream.
sourceraw docstring

load-workbook-from-fileclj

(load-workbook-from-file file)

Load an Excel .xls or .xlsx workbook from a file.

Load an Excel .xls or .xlsx workbook from a file.
sourceraw docstring

load-workbook-from-resourceclj

(load-workbook-from-resource resource)

Load an Excel workbook from a named resource. Used when reading from a resource on a classpath as in the case of running on an application server.

Load an Excel workbook from a named resource.
Used when reading from a resource on a classpath
as in the case of running on an application server.
sourceraw docstring

load-workbook-from-streamclj

(load-workbook-from-stream stream)

Load an Excel workbook from a stream. The caller is required to close the stream after loading is completed.

Load an Excel workbook from a stream.
The caller is required to close the stream after loading is completed.
sourceraw docstring

read-cellcljmultimethod

source

read-cell-valuecljmultimethod

source

remove-all-rows!clj

(remove-all-rows! sheet)

Remove all the rows from the sheet.

Remove all the rows from the sheet.
sourceraw docstring

remove-row!clj

(remove-row! sheet row)

Remove a row from the sheet. Rows are not shifted up - the removed row will display as blank

Remove a row from the sheet. Rows are not shifted up - the removed row will display as blank
sourceraw docstring

row-seqclj

(row-seq sheet)

Return a lazy sequence of the rows in a sheet. Missing rows will be returned as nil filter with e.g. (remove nil? (row-seq ...)) if missing rows are not needed

Return a lazy sequence of the rows in a sheet. Missing rows will be returned as nil
filter with e.g. (remove nil? (row-seq ...)) if missing rows are not needed
sourceraw docstring

row-vecclj

(row-vec column-order row)

Transform the row struct (hash-map) to a row vector according to the column order. Example:

(row-vec [:foo :bar] {:foo "Foo text", :bar "Bar text"})

["Foo text" "Bar text"]

Transform the row struct (hash-map) to a row vector according to the column order.
Example:

  (row-vec [:foo :bar] {:foo "Foo text", :bar "Bar text"})
  > ["Foo text" "Bar text"]
sourceraw docstring

save-workbook!cljmultimethod

Save the workbook into a stream or a file. In the case of saving into a stream, the caller is required to close the stream after saving is completed.

Save the workbook into a stream or a file.
In the case of saving into a stream, the caller is required
to close the stream after saving is completed.
sourceraw docstring

save-workbook-into-file!clj

(save-workbook-into-file! filename workbook)

Save the workbook into a file.

Save the workbook into a file.
sourceraw docstring

save-workbook-into-stream!clj

(save-workbook-into-stream! stream workbook)

Save the workbook into a stream. The caller is required to close the stream after saving is completed.

Save the workbook into a stream.
The caller is required to close the stream after saving is completed.
sourceraw docstring

select-cellclj

(select-cell n sheet)

Given a Sheet and a cell reference (A1), select-cell returns the cell or nil if the cell could not be found

Given a Sheet and a cell reference (A1), select-cell returns the cell
or nil if the cell could not be found
sourceraw docstring

select-columnsclj

(select-columns column-map sheet)

Takes two arguments: column hashmap and a sheet. The column hashmap specifies the mapping from spreadsheet columns dictionary keys: its keys are the spreadsheet column names and the values represent the names they are mapped to in the result.

For example, to select columns A and C as :first and :third from the sheet

(select-columns {:A :first, :C :third} sheet) => [{:first "Value in cell A1", :third "Value in cell C1"} ...]

Takes two arguments: column hashmap and a sheet. The column hashmap
specifies the mapping from spreadsheet columns dictionary keys:
its keys are the spreadsheet column names and the values represent
the names they are mapped to in the result.

For example, to select columns A and C as :first and :third from the sheet

(select-columns {:A :first, :C :third} sheet)
=> [{:first "Value in cell A1", :third "Value in cell C1"} ...] 
sourceraw docstring

select-nameclj

(select-name workbook n)

Given a workbook and name (string or keyword) of a named range, select-name returns a seq of cells or nil if the name could not be found.

Given a workbook and name (string or keyword) of a named range, select-name
returns a seq of cells or nil if the name could not be found.
sourceraw docstring

select-sheetcljmultimethod

Select a sheet from the workbook by name, regex or arbitrary predicate

Select a sheet from the workbook by name, regex or arbitrary predicate
sourceraw docstring

set-cell!cljmultimethod

source

set-cell-comment!clj

(set-cell-comment! cell
                   comment-str
                   &
                   {:keys [font width height] :or {width 1 height 2}})

Creates a cell comment-box that displays a comment string when the cell is hovered over. Returns the cell.

Options:

:font (font | fontmap - font applied to the comment string) :width (int - width of comment-box in columns; default 1 cols) :height (int - height of comment-box in rows; default 2 rows)

Example:

(set-cell-comment! acell "This comment should span two lines." :width 2 :font {:bold true :size 12 :color blue})

Creates a cell comment-box that displays a comment string
   when the cell is hovered over. Returns the cell.

   Options:

   :font   (font | fontmap - font applied to the comment string)
   :width  (int - width of comment-box in columns; default 1 cols)
   :height (int - height of comment-box in rows; default 2 rows)

   Example:

   (set-cell-comment! acell "This comment should
span two lines."
                     :width 2 :font {:bold true :size 12 :color blue})
   
sourceraw docstring

set-cell-style!clj

(set-cell-style! cell style)

Apply a style to a cell. See also: create-cell-style!.

Apply a style to a cell.
See also: create-cell-style!.
sourceraw docstring

set-row-style!clj

(set-row-style! row style)

Apply a style to all the cells in a row. Returns the row.

Apply a style to all the cells in a row.
Returns the row.
sourceraw docstring

set-row-styles!clj

(set-row-styles! row styles)

Apply a seq of styles to the cells in a row. Cells that are missing won't be assigned a style - if you want to style missing cells, create them first

Apply a seq of styles to the cells in a row.
Cells that are missing won't be assigned a style - if you want to style missing cells, create them first
sourceraw docstring

sheet-nameclj

(sheet-name sheet)

Return the name of a sheet.

Return the name of a sheet.
sourceraw docstring

sheet-seqclj

(sheet-seq workbook)

Return a lazy seq of the sheets in a workbook.

Return a lazy seq of the sheets in a workbook.
sourceraw docstring

string-cell?clj

(string-cell? cell)
source

vert-alignclj

(vert-align kw)

Returns vertical alignment

Returns vertical alignment
sourceraw docstring

whenscljmacro

(whens & [test expr :as clauses])

Processes any and all expressions whose tests evaluate to true. Example: (let [m (java.util.HashMap.)] (whens false (.put m :z 0) true (.put m :a 1) true (.put m :b 2) nil (.put m :w 3)) m) => {:b=2, :a=1}

Processes any and all expressions whose tests evaluate to true.
Example:
(let [m (java.util.HashMap.)]
 (whens
  false (.put m :z 0)
  true  (.put m :a 1)
  true  (.put m :b 2)
  nil   (.put m :w 3))
 m)
=> {:b=2, :a=1}
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close