Liking cljdoc? Tell your friends :D

psosf.model

Building, traversing and editing PSOSF archives as Clojure data.

Every function is pure: it takes an archive (or a worksheet) and returns a new one. Nothing here touches files or JSON; use psosf.core to read, write and classify.

Cell content is {:kind :text :text "..."} or {:kind :formula :text "=..."}. Wherever content is accepted, a plain string is taken as text and (formula "=A1+1") builds a formula. Values are kept as text, as PSOSF stores them.

The manifest stays a map with string keys, exactly as in manifest.json, so an archive always writes back in canonical form.

(-> (archive "Account Balances" {:namespace "com.example.ledger"}) (add-sheet (-> (sheet "Accounts") (add-column {:header "id" :type "text"}) (add-column {:header "amount" :type "number" :annotation ["Balance in US dollars."]}) (add-column {:header "negative" :type "boolean" :annotation ["pebblestream:fail"]}) (add-row ["1" "435" (formula "=B2<0")]))))

Building, traversing and editing PSOSF archives as Clojure data.

Every function is pure: it takes an archive (or a worksheet) and returns a
new one. Nothing here touches files or JSON; use psosf.core to read, write
and classify.

Cell content is {:kind :text :text "..."} or {:kind :formula :text "=..."}.
Wherever content is accepted, a plain string is taken as text and
(formula "=A1+1") builds a formula. Values are kept as text, as PSOSF stores
them.

The manifest stays a map with string keys, exactly as in manifest.json, so
an archive always writes back in canonical form.

(-> (archive "Account Balances" {:namespace "com.example.ledger"})
    (add-sheet (-> (sheet "Accounts")
                   (add-column {:header "id"     :type "text"})
                   (add-column {:header "amount" :type "number"
                                :annotation ["Balance in US dollars."]})
                   (add-column {:header "negative" :type "boolean"
                                :annotation ["pebblestream:fail"]})
                   (add-row ["1" "435" (formula "=B2<0")]))))
raw docstring

add-annotation-lineclj/s

(add-annotation-line sheet header line)

Appends one line (a directive or a comment) to a column's annotation.

Appends one line (a directive or a comment) to a column's annotation.
sourceraw docstring

add-columnclj/s

(add-column sheet spec)

Adds a column at the end (or at :index). Existing rows get an empty cell.

Adds a column at the end (or at :index). Existing rows get an empty cell.
sourceraw docstring

add-rowclj/s

(add-row sheet values)

Appends a row: a vector of values in column order, or a map of header to value. Missing values are empty.

Appends a row: a vector of values in column order, or a map of header to
value. Missing values are empty.
sourceraw docstring

add-sheetclj/s

(add-sheet archive sheet)

Adds a worksheet at the end. Throws if the name is taken.

Adds a worksheet at the end. Throws if the name is taken.
sourceraw docstring

archiveclj/s

(archive name)
(archive name {:keys [namespace description license]})

A new, empty version 1.1 archive. Options: :namespace, :description, :license {:name :url :spdx}.

A new, empty version 1.1 archive. Options: :namespace, :description,
:license {:name :url :spdx}.
sourceraw docstring

assoc-manifestclj/s

(assoc-manifest archive k v)

Sets a manifest value. "format", "format-version" and "sheets" are managed by the archive and cannot be set.

Sets a manifest value. "format", "format-version" and "sheets" are
managed by the archive and cannot be set.
sourceraw docstring

cellclj/s

(cell sheet row header)

Content at a zero-based data row and a header, or nil.

Content at a zero-based data row and a header, or nil.
sourceraw docstring

columnclj/s

(column {:keys [header type annotation style] :or {type "text"}})

A column. :annotation is a list of lines: strings beginning with pebblestream: are directives, other strings are comments.

A column. :annotation is a list of lines: strings beginning with
pebblestream: are directives, other strings are comments.
sourceraw docstring

column-indexclj/s

(column-index sheet header)

The zero-based index of the column with this header, or nil.

The zero-based index of the column with this header, or nil.
sourceraw docstring

commentsclj/s

(comments sheet)

Every comment line in the worksheet's annotations.

Every comment line in the worksheet's annotations.
sourceraw docstring

directivesclj/s

(directives sheet)

Every directive line in the worksheet's annotations: ({:column "amount" :text "pebblestream:fail"} ...).

Every directive line in the worksheet's annotations:
({:column "amount" :text "pebblestream:fail"} ...).
sourceraw docstring

find-columnclj/s

(find-column sheet header)
source

find-sheetclj/s

(find-sheet archive name)

The worksheet with this name, or nil.

The worksheet with this name, or nil.
sourceraw docstring

formulaclj/s

(formula text)

Formula content. text must begin with =.

Formula content. text must begin with =.
sourceraw docstring

formula?clj/s

(formula? content)
source

formulasclj/s

(formulas sheet)

Every formula cell: ({:row 0 :column "negative" :text "=B2<0"} ...). :row is zero-based over data rows; in Excel it is row (+ row 2).

Every formula cell: ({:row 0 :column "negative" :text "=B2<0"} ...).
:row is zero-based over data rows; in Excel it is row (+ row 2).
sourceraw docstring

headersclj/s

(headers sheet)
source

manifest-getclj/s

(manifest-get archive k)

A manifest value by key, e.g. (manifest-get a "namespace").

A manifest value by key, e.g. (manifest-get a "namespace").
sourceraw docstring

remove-columnclj/s

(remove-column sheet header)
source

remove-rowclj/s

(remove-row sheet row)
source

remove-sheetclj/s

(remove-sheet archive name)
source

rename-sheetclj/s

(rename-sheet archive old-name new-name)

Renames a worksheet. References to it inside formulas and directives are not rewritten.

Renames a worksheet. References to it inside formulas and directives are
not rewritten.
sourceraw docstring

row-countclj/s

(row-count sheet)
source

row-valuesclj/s

(row-values sheet)

Rows as maps of header to text: a value's text, or a formula's text.

Rows as maps of header to text: a value's text, or a formula's text.
sourceraw docstring

rowsclj/s

(rows sheet)

Rows as maps of header to content.

Rows as maps of header to content.
sourceraw docstring

set-annotationclj/s

(set-annotation sheet header lines)

Replaces a column's annotation with these lines (strings or line maps).

Replaces a column's annotation with these lines (strings or line maps).
sourceraw docstring

set-cellclj/s

(set-cell sheet row header value)

Sets the content at a zero-based data row and a header.

Sets the content at a zero-based data row and a header.
sourceraw docstring

set-licenseclj/s

(set-license archive license)

Sets the license: {:name "Apache License 2.0" :url "..." :spdx "Apache-2.0"}.

Sets the license: {:name "Apache License 2.0" :url "..." :spdx "Apache-2.0"}.
sourceraw docstring

set-styleclj/s

(set-style sheet header style)
source

set-typeclj/s

(set-type sheet header type)
source

sheetclj/s

(sheet name)

A new worksheet with no columns.

A new worksheet with no columns.
sourceraw docstring

sheet-namesclj/s

(sheet-names archive)
source

sheetsclj/s

(sheets archive)
source

textclj/s

(text s)
source

update-columnclj/s

(update-column sheet header f & args)

Applies f to the column map with this header.

Applies f to the column map with this header.
sourceraw docstring

update-sheetclj/s

(update-sheet archive name f & args)

Applies f (and args) to the named worksheet.

Applies f (and args) to the named worksheet.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close