# Standard spreadsheet reference

This appendix is a reference of the standard spreadsheet module.

## Standard spreadsheet module

Symbol | Description
--- | ---
afnix-sps | module
afnix:sps | nameset

Cell

The `Cell` class is a data container. There is only one data element per cell. Eventually a name can be associated with a cell. The cell data can be any kind of literals. Such literals are integer, real, boolean, character or strings. A cell is the basic block used to build a spreadsheet.

cell-p
Object
Cell
none

The `Cell` constructor create a default cell with no name and no value. When evaluated, the cell returns nil.

Cell
Literal

The `Cell` constructor create a default cell by value. The argument is a literal object which can be viewed with its string representation.

Cell
String Literal

The `Cell` constructor create a default cell by name and value. The first argument is the cell name. The second argument is a literal object which can be viewed with its string representation.

get
Literal
none

The `get` method returns the cell literal value.

set
none
Literal

The `set` method sets the cell literal value.

get-name
String
none

The `get-name` method returns the cell name.

set-name
none
String

The `set-name` method sets the cell name.

Record

The `Record` class is a cell container. A record can be created by adding cell or simply by adding data. If the record has a predefined size, the cell or data can be set by indexing. A name can be attached to the record. Facilities are provided to access directly the cell associated with the record. A record can also be created by name.

record-p
Object
Record
none

The `Record` constructor create an empty record with no name and no cell.

Record
String

The `Record` constructor create an empty record by name name. The argument is the record name to use.

add
none
Cell|Literal...

The `add` method adds one or several cell objects to the record. In the first form, the argument is a cell that is added in the record. In the second form, the argument is a literal that is used to create a cell by value.

get
Cell
Integer

The `get` method returns a record cell by index. The index must be within the record range or an exception is raised.

map
Literal
Integer

The `map` method map a record cell by index. The index must be within the record range or an exception is raised. The cell is mapped to a literal object.

set
none
Integer Cell|Literal

The `set` method sets the record cell by index. The record index must be valid in order to succeed. A new cell is created prior the record update. The previous cell data is lost including its name.

sort
none
none|Boolean

The `sort` method sorts a record in place. Without argument, the record is sorted in ascending order. The optional boolean argument specifies the sorting mode. If true, the record is sorting in ascending order and in descending order if false.

find
Cell
String

The `find` method finds a cell by name. If the cell is not found, the nil object is returned. This method is similar to the `lookup` method.

get-index
Integer
String

The `get-index` method finds a cell index by name. If the cell is not found, an exception is raised. The index is the cell position in the record.

lookup
Cell
String

The `lookup` method finds a cell by name. If the cell is not found, an exception is raised. This method is similar to the `find` method.

length
Integer
none

The `length` method returns the record length.

get-name
String
none

The `get-name` method returns the record name.

reset
none
none

The `reset` method rest the record. The record name is not changed but all record cells are removed.

set-name
none
String

The `set-name` method sets the record name.

Sheet

The `Sheet` class is a record container. A sheet can be created by adding records. Similarly, if the sheet has a predefined size, record cell or data can be added by indexing. A sheet can be also seen as a 2 dimensional array of cells. Like a record, a sheet can be named. Without argument, a default sheet is created. With a string argument, the sheet is created with an initial name.

sheet-p
Object
Sheet
none

The `Sheet` constructor create an empty sheet with no name and no cell.

Sheet
String

The `Sheet` constructor create an empty sheet by name. The argument is the sheet name to use.

Sheet
String String

The `Sheet` constructor create an empty sheet by name and info. The first argument is the sheet name to use. The second argument is the sheet information string.

add
none
Record

The `add` method adds a record to the sheet.

get
Record
Integer

The `get` method returns a sheet record by index. The index must be within the sheet range or an exception is raised.

set
none
Integer Record

The `set` method sets the sheet record by index. The sheet index must be valid in order to succeed.

sort
none
none|Integer|Boolean|Integer Boolean

The `sort` method sorts the sheet in place. By default, the sheet is sorted in ascending order with column 0. With one argument, the argument can be either the sorting mode or the column number. If the mode is true, the sheet is sorted in ascending mode. If the mode is false, the sheet is sorted in descending mode. With two arguments, the first argument is the column number and the second is the sorting mode.

length
Integer
none

The `length` method returns the sheet length.

convert
PrintTable
[Integer [Integer [Boolean]]]

The `convert` method converts the sheet into a print-table representation. Without argument, the whole sheet is converted. With one argument, the sheet is converted unto a maximum of rows. The second optional argument is the start index that default to 0. The third optional argument is the literal format. By default, the literal is formatted as a string. If the flag is true, the literal is formatted as a literal string representation.

add-data
none
[Cell|Literal]+

The `add-data` method adds one or several cell object to a sheet record. The sheet record is initially created and the object elements are added sequentially to the record. In the first form, the argument is a cell that is added in the record. In the second form, the argument is a literal that is used to create a cell by value.

add-marker
none
[Literal]+

The `add-marker` method adds one or several literal objects to a sheet marker record.

marker-length
Integer
none

The `marker-length` method returns the number of markers defined for this sheet.

get-marker
Cell
Integer

The `get-marker` method returns a marker cell by index from the sheet marker record.

set-marker
none
Integer Literal

The `set-marker` method set the sheet marker record by index and literal.

find-marker
Integer
String

The `find-marker` method find the marker index. The argument is the marker string value.

add-sign
none
[Literal]+

The `add-sign` method adds one or several literal objects to a sheet sign record.

signature-length
Integer
none

The `signature-length` method returns the number of signs defined for this sheet.

get-sign
Cell
Integer

The `get-sign` method returns a sign cell by index from the sheet sign record.

set-sign
none
Integer Literal

The `set-sign` method set the sheet sign record by index and literal.

find-sign
Integer
String

The `find-sign` method find the sign index. The argument is the sign string value.

add-header
none
Cell|Literal...

The `add-header` method adds one or several cell object to a sheet header record. In the first form, the argument is a cell that is added in the record. In the second form, the argument is a literal that is used to create a cell by value.

get-header
Cell
Integer

The `get-header` method returns a header cell by index from the sheet header record.

map-header
Literal
Integer

The `map-header` method maps to a literal object a header cell by index from the sheet header record.

set-header
none
Integer Literal

The `set-header` method set the header record by index and literal. The cell associated with the header record is updated with the literal value.

add-footer
none
[Cell|Literal]+

The `add-footer` method adds one or several cell object to a sheet footer record. In the first form, the argument is a cell that is added in the record. In the second form, the argument is a literal that is used to create a cell by value.

get-footer
Cell
Integer

The `get-footer` method returns a footer cell by index from the sheet footer record.

map-footer
Literal
Integer

The `map-footer` method maps to a literal object an footer cell by index from the sheet footer record.

set-footer
none
Integer Literal

The `set-footer` method set the footer record by index and literal. The cell associated with the footer record is updated with the literal value.

get-name
String
none

The `get-name` method returns the sheet name.

set-name
none
String

The `set-name` method sets the sheet name.

get-info
String
none

The `get-info` method returns the sheet info.

set-info
none
String

The `set-info` method sets the sheet info.

add-tag
none
[String]+

The `add-tag` method adds a tag into the tags vector. The tag can be used to mark a sheet in a folio.

tag-p
Boolean
string

The `tag-p` method returns true if the given tag is defined for this sheet.

tag-length
Integer
none

The `tag-length` method returns the number of tags defined for this sheet.

get-tag
String
Integer

The `get-tag` method returns a tag by index.

set-tag
none
Integer Literal

The `set-tag` method set the sheet tag record by index and literal.

find-tag
Integer
String

The `find-tag` method find the tag index. The argument is the tag string value.

reset
none
none

The `reset` method resets the sheet. The name and information is unchanged during this operation.

Folio

The `Folio` class is a sheet container. A folio of sheets can be structured to handle various data organization. Since all objects are named, it is possible to index them for fast data search. An empty folio can be created by name or filled with an input stream.

folio-p
Object
Folio
none

The `Folio` constructor create an empty folio with no name and no cell.

Folio
String

The `Folio` constructor create an empty folio by name. The argument is the folio name to use.

Folio
String String

The `Folio` constructor create an empty folio by name and info. The first argument is the folio name to use. The second argument is the folio information string.

Folio
Input

The `Folio` constructor create an empty folio and fill it by reading the data from the input stream. The input stream must have the data in a serialized form.

write
none
Output

The `write` method write the folio contents to an output stream. The written form is a serialized form.

add
none
Sheet

The `add` method adds a sheet to the folio.

get
Sheet
Integer

The `get` method returns a sheet by index. The index must be within the folio range or an exception is raised.

set
none
Integer Sheet

The `set` method sets the folio by index and sheet. The index must be within the folio range or an exception is raised.

tag-p
Boolean
String

The `tag-p` method returns true if a sheet with the tag argument exists in the folio.

find
Sheet
String

The `find` method finds a sheet by tag. The first found sheet those tag is matched is returned. In the case that multiple sheet share the same tag, the `filter` should be used. If no sheet is found the method return the nil object.

lookup
Sheet
String

The `lookup` method finds a sheet by tag. The first found sheet those tag is matched is returned. In the case that multiple sheet share the same tag, the `filter` should be used. If no sheet is found the method throws an exception. This method is similar to the `find` method.

filter
Folio
String

The `filter` method return a new folio with sheets that match the argument tag. If no sheet is found, the folio is empty.

reset
none
none

The `reset` method resets the folio. The name and information is unchanged during this operation.

length
Integer
none

The `length` method returns the folio length.

get-name
String
none

The `get-name` method returns the folio name.

set-name
none
String

The `set-name` method sets the folio name.

get-info
String
none

The `get-info` method returns the folio info.

set-info
none
String

The `set-info` method sets the folio info.

get-xref
Xref
none|Integer|String|Integer Integer

The `get-xref` method returns a cross-reference table from the folio. Without argument, the whole folio is scanned and all named cells are added in the cross-reference table. With an integer argument, all cells that matches the cell index argument are added in the cross-reference table. With a string argument, all cells that have the same name are added in the table. Finally, with two arguments that represents the cell index and the record index are used, all cells are added in the table with these two coordinates.

Index

The `Index` class is a class that maintain a cell index at the folio level. A cell index is composed of the sheet index, the record index and the cell index. The index object can be used to access in a generic way a particular cell. Additionally, the folio name can also be stored in the index. It is possible to have multiple records that represents the same cell.

index-p
Object
Index
none

The `Index` constructor creates an empty index.

Index
Integer

The `Index` constructor creates an index with a cell index as its coordinate.

Index
Integer Integer

The `Integer` constructor creates an index with a cell and record indexes as its coordinate. The first argument is the cell index. The second argument is the record index.

Index
Integer Integer Integer

The `Index` constructor creates an index with a cell, record and sheet indexes as its coordinate. The first argument is the cell index. The second argument is the record index. The third argument is the sheet index.

add
none
Integer|Integer Integer|Integer Integer Integer

The `add` method adds a new index coordinate in the index object. In the first form, the cell index is used as the coordinate. In the second form, the cell and record indexes are used as the coordinate. In the third form, the cell, record and sheet indexes are used as the coordinate.

reset
none
none

The `reset` method reset the index by removing all attached coordinates.

length
Integer
none

The `length` method returns the index length. The index length is the number of coordinate entries in the index.

exists-p
Boolean
Integer|Integer Integer|Integer Integer Integer

The `exists-p` predicate returns true if a coordinate entry exists in the index. In the first form, the cell index is used as the coordinate. In the second form, the cell and record indexes are used as the coordinate. In the third form, the cell, record and sheet indexes are used as the coordinate.

set-index-cell
none
Integer Integer

The `set-index-cell` method sets the cell index by position. The first argument is the coordinate position. The second argument is the cell index to use.

update-index-cell
none
Integer

The `update-index-cell` method updates the cell index for all entries in the index. The argument is the new cell index to use for the update process.

get-index-cell
Integer
Integer

The `get-index-cell` method returns the cell index for a particular entry. The argument is the entry position.

set-index-record
none
Integer Integer

The `set-index-record` method sets the record index by position. The first argument is the coordinate position. The second argument is the record index to use.

update-index-record
none
Integer

The `update-index-record` method updates the record index for all entries in the index. The argument is the new record index to use for the update process.

get-index-record
Integer
Integer

The `get-index-record` method returns the record index for a particular entry. The argument is the entry position.

set-index-sheet
none
Integer Integer

The `set-index-sheet` method sets the sheet index by position. The first argument is the coordinate position. The second argument is the cell sheet to use.

update-index-sheet
none
Integer

The `update-index-sheet` method updates the sheet index for all entries in the index. The argument is the new sheet index to use for the update process.

get-index-sheet
Integer
Integer

The `get-index-sheet` method returns the sheet index for a particular entry. The argument is the entry position.

Xref

The `Xref` class is a cross-reference class. The class maintains the association between a name and an index. with a particular name, an index entry is created if it does not exists. Such entry can be later used to access the cell content by index.

xref-p
Object
Xref
none

The `Xref` constructor creates an empty cross-reference object.

add
none
String [Integer|Integer Integer|Integer Integer Integer]

The `add` method adds a new reference in the table. The first argument is always the index name. In the first form, the cell index is used as the coordinate. In the second form, the cell and record indexes are used as the coordinate. In the third form, the cell, record and sheet indexes are used as the coordinate.

get
Index
Integer|String

The `get` method returns an `Index` object either by name or position. With an integer argument, the index is obtained by position. With a string argument, the index with the matching name is returned.

reset
none
none

The `reset` method resets the cross-reference table.

length
Integer
none

The `length` method returns the length of the cross-reference table.

lookup
Index
String

The `lookup` method returns an index those name is the matching argument. If the index cannot be found, an exception is raised.

exists-p
Boolean
String

The `exists-p` predicate returns true if an index those name is the matching argument exists in the cross-reference table.

get-name
String
Integer

The `get-name` method returns the index name by position.