Class - API Usage
Path:
/src/index.coffee
compiled to/lib/index.js
The exported class allows you to work with table data using it’s class methods or by creating an instance.
Static Conversion
To convert from and to the different data structures described above, you can use the following 4 methods:
CoffeeScript Code result = Table.fromRecordList recordList
result = Table.fromRecordObject recordObject, idColumn
result = Table.toRecordList example
result = Table.toRecordObject example
The conversion to record object will loose the name of the first column so it will always get ‘ID’ on back conversion '‘fromRecordObject’ if not defined otherwise.
fromRecordList()
Convert from record list to table structure.
Usage: static
fromRecordList(obj)
- Parameter
-
obj
-Array<Object>
record list to read
- Return
Array<Array>
table structure
toRecordList()
Convert from table structure to record list.
Usage: static
toRecordList(obj)
- Parameter
-
obj
-Array<Array>
table structure
- Return
Array<Object>
record list to read
fromRecordObject()
Convert from record object to table structure.
Usage: static
fromRecordObject(obj, idColumn)
- Parameter
-
obj
-Object<Object>
record object to readidColumn
-String
optional title for the id column to be used
- Return
Array<Array>
table structure
toRecordObject()
Convert from table structure to record object.
Usage: static
toRecordObject(obj)
- Parameter
-
obj
-Array<Array>
table structure
- Return
Object<Object>
record object to read
Static Access
This methods allows you to easily read and edit the table data in your code.
field()
This method is used to access cell values or set them.
Examples
Read a cell value:
CoffeeScript Code value = Table.field example, 1, 1
# will result value of field 1/1
value = Table.field example, 1, 'Name'
# do the same but using the column name
And set a new value to a defined cell:
CoffeeScript Code Table.field example, 1, 1, 15.8
# will set value of field 1/1
Table.field example, 1, 'Name', 15.8
# do the same but using the column name
Usage: static
field(obj, row, column, value)
- Parameter
-
obj
-Array<Array>
to accessrow
-Integer
number from 1… (0 is the heading)column
-Integer|String
number of column 0… or the name of a columnvalue
- optional new value for the given cell
- Return
- the current (new) value of the given cell
row()
Get or set a complete table row.
Examples
First you may read one row as record:
CoffeeScript Code record = Table.row example, 1
# may return something like {ID: 1, Name: 'one'}
And then you may also overwrite it with a changed version:
CoffeeScript Code Table.row example, 1, {ID: 3, Name: 'three'}
Usage: static
row(obj, row, value)
- Parameter
-
obj
-Array<Array>
to accessrow
-Integer
number from 1… (0 is the heading)value
-Array
optional new value for the given row
- Return
- the defined row as object
insert()
Insert multiple rows into the Table.
Examples
CoffeeScript Code result = Table.insert example, 2, [
[5, 'five']
[6, 'six']
]
If you want to insert record list or record object data you have to convert them first.
Usage: static
insert(obj, pos, rows)
- Parameter
-
obj
-Array<Array>
table to accesspos
-Integer
row position from 1… (0 is the heading) use ‘null’ to add at the endrows
-Array|Array<Array>
table rows to add
- Return
Array<Array>
the changed object
delete()
Delete some rows.
Examples
CoffeeScript Code # delete the second data row:
result = Table.delete example, 2
# delete the second and third data row:
result = Table.delete example 2, 2
Usage: static
delete(obj, pos, num)
- Parameter
-
obj
-Array<Array>
table to accesspos
-Integer
row number from 1… (0 is the heading)num
-Integer
optional number of rows to delete (defaults to 0)
- Return
Array<Array>
the changed object
shift()
Remove the first row as record object from the table. The header will be kept.
Examples
CoffeeScript Code record = Table.shift example
# record = {ID: 1, Name: 'one'}
Usage: static
shift(obj)
- Parameter
-
obj
-Array<Array>
table to access
- Return
Object
the first, removed record
unshift()
Add record object to the start of the table.
Examples
CoffeeScript Code Table.unshift example, {id: 0, Name: 'zero'}
Usage: static
unshift(obj, record)
- Parameter
-
obj
-Array<Array>
table to accessrecord
-Object
record to add
- Return
Object
the changed table structure
pop()
Remove the last row as record object from the table. The header will be kept.
Examples
CoffeeScript Code record = Table.pop example
# record = {ID: 3, Name: 'three'}
Usage: static
pop(obj)
- Parameter
-
obj
-Array<Array>
table to access
- Return
Object
the last row
push()
Add record object to the end of the table.
Examples
CoffeeScript Code Table.push example, {id: 4, Name: 'four'}
Usage: static
push(obj, record)
- Parameter
-
obj
-Array<Array>
table to accessrecord
-Object
to add
- Return
Object
the just added record
column()
Get a defined column as array.
The column number will start at 0…
Examples
CoffeeScript Code result = Table.column example, 'Name'
# result = ['one', 'two', 'three']
Usage: static
column(table, column, values)
- Parameter
-
table
-Array<Array>
to accesscolumn
-Integer|String
the column to exportvalues
-Array
optional values for row 1…
- Return
Array
values for the column fields from row 1… The header name is not included.
columnAdd()
Get a defined column.
Examples
You may only add a column (here as second column - index 1):
CoffeeScript Code Table.columnAdd example, 1, 'DE'
# table.data = [
# [ 'ID', 'DE', 'Name' ]
# [ 1, null, 'one' ]
# [ 2, null, 'two' ]
# [ 3, null, 'three' ]
# ]
Or also add values for this column:
CoffeeScript Code Table.columnAdd example, 1, 'DE', ['eins', 'zwei', 'drei']
# table.data = [
# [ 'ID', 'DE', 'Name' ]
# [ 1, 'eins', 'one' ]
# [ 2, 'zwei', 'two' ]
# [ 3, 'drei', 'three' ]
# ]
Usage: static
columnAdd(table, column, name, values)
- Parameter
-
table
-Array<Array>
structure to accesscolumn
-Integer|String
position there inserting new columnname
-String
of the new columnvalues
-Array
optional values for row 1…
columnRemove()
Get a defined column.
Examples
This will remove the first column with the ID and keep only the Name column:
CoffeeScript Code Table.columnRemove example, 0
# table = [
# [ 'Name' ]
# [ 'one' ]
# [ 'two' ]
# [ 'three' ]
# ]
Usage: static
columnRemove(table, column)
- Parameter
-
table
-Array<Array>
structure to accesscolumn
-Integer|String
position there deleting column
Static Join
There are basically two methods of appending. First vertivally by appending the tables below each one. And second vertically by combining the rows.
append()
This may append two tables under each other. The resulting table will have the columns from both of them.
Examples
CoffeeScript Code table.append [
[4, 'four']
[5, 'five']
[6, 'six']
]
# table.data = [
# ['ID', 'Name']
# [1, 'one']
# [2, 'two']
# [3, 'three']
# [4, 'four']
# [5, 'five']
# [6, 'six']
# ]
Usage: static
append(table, table2, ...)
- Parameter
-
table
-Array<Array>
the table structure to use as basetable2
-Array<Array>
to append...
-Array<Array>
more tables
- Return
Array<Array>
the changed table
join()
This works like a sql database join and if it is possible better use it within the database because of the performance.
Examples
CoffeeScript Code Table.join example, 'left', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 1, 'one', null ]
# [ 2, 'two', 'zwei' ]
# [ 3, 'three', null ]
# ]
CoffeeScript Code Table.join example, 'right', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 2, 'two', 'zwei' ]
# [ null, 'seven', 'sieben' ]
# ]
CoffeeScript Code Table.join example, 'inner', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 2, 'two', 'zwei' ]
# ]
CoffeeScript Code Table.join example, 'outer', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 1, 'one', null ]
# [ 3, 'three', null ]
# [ null, 'seven', 'sieben' ]
# ]
Usage: static
join(table, type, table2, ...)
- Parameter
-
table
-Array<Array>
the table structure to use as basetype
-String
type of join like: ‘left’, ‘inner’, ‘right’, ‘outer’table2
-Array<Array>
to join...
-Array<Array>
more tables
- Return
Array<Array>
the changed table
Static Transform
sort()
Sort the data rows by the specified columns.
Examples
CoffeeScript Code # sort after Name column
Table.sort example, 'Name'
# reverse sort
Table.sort example, '-Name'
# sort after ID then Name
Table.sort example, ['ID', 'Name']
# the same
Table.sort example, 'ID, Name'
Usage: static
sort(table, sort)
- Parameter
-
table
-Array<Array>
the table structure to use as basesort
-String|Array
columns to order by. The sort columns may be number or names as array or comma delimited string. To sort. For reverse order prepend the column with ‘-’.
- Return
Array<Array>
the changed table
reverse()
Reverse the order of all data rows in the table.
Examples
CoffeeScript Code Table.reverse example
Usage: static
reverse(table)
- Parameter
-
table
-Array<Array>
the table structure to use as base
- Return
Array<Array>
the changed table
flip()
You may switch the x-axis and y-axis of your table.
Examples
CoffeeScript Code Table.flip example
# table.data = [
# [ 'ID', 1, 2, 3 ]
# [ 'Name', 'one', 'two', 'three' ]
# ]
Usage: static
flip(table)
- Parameter
-
table
-Array<Array>
the table structure to use as base
- Return
Array<Array>
the new table
format()
Format column values.
The format is defined like the validator schema or a user defined function which will be called with the cell value and should return the formatted value.
Examples
CoffeeScript Code Table.format examples,
ID:
type: 'percent'
format: '0%'
Name:
type: 'string'
upperCase: 'first'
# table.data = [
# [ 'ID', 'Name' ]
# [ '100%', 'One' ]
# [ '200%', 'Two' ]
# [ '300%', 'Three' ]
# ]
And with custom functions the call should look like:
CoffeeScript Code Table.format examples,
Name: (cell) -> cell.toString().toUpperCase()
Usage: static
format(table, formats)
- Parameter
-
table
-Array<Array>
the table structure to use as baseformats
-Array|Object
for the columns- array with each columns format
- object with ‘column: format’
- Return
Array<Array>
the changed table
rename()
Rename a column.
Examples
CoffeeScript Code Table.rename example, 'Name', 'EN'
Usage: static
rename(table, col, name)
- Parameter
-
table
-Array<Array>
the table structure to use as basecol
-Integer|String
column to renamename
-String
new name for defined column
- Return
Array<Array>
the changed table
Static Filtering
columns()
Rename multiple columns, reorder them and filter them.
The columns can be defined all using true, meaning to use them in the existing order or with the number or name so a resorting is also possible in one step.
Examples
In the following example only the first two columns are kept and named:
CoffeeScript Code Table.columns example,
ID: true
EN: true
# table.data = [
# [ 'ID', 'EN' ]
# [1, 'one']
# [2, 'two']
# [3, 'three']
# ]
And here the columns are also reordered:
CoffeeScript Code Table.columns example,
EN: 'Name'
ID: 'ID'
# table.data = [
# ['EN', 'ID']
# ['one', 1]
# ['two', 2]
# ['three', 3]
# ]
Usage: static
columns(table, columns)
- Parameter
-
table
-Array<Array>
the table structure to use as basecolumns
-Object<String>
column name: column to use
- Return
Array<Array>
the new table structure
unique()
Remove all duplicate data rows.
Examples
CoffeeScript Code # remove all completely duplicate rows
Table.unique example
# remove all rows with duplicate Name column
Table.unique example, 'Name'
Usage: static
unique(table, columns)
- Parameter
-
table
-Array<Array>
the table structure to use as basecolumns
-Integer|String|Array
to check for uniqueness
- Return
Array<Array>
the changed table
filter()
Filter the rows using specific conditions per column.
The conditions are strings consisting of ’
CoffeeScript Code conditions = ['Name not null', ['Name startsWith a', 'Name startsWith b']]
This results in the following logic:
Name not null
# and
Name startsWith a
# or
Name startsWith b
Examples
CoffeeScript Code Table.filter example, ['ID > 1', 'ID < 8'] # AND
Table.filter example, [['ID < 2', 'ID > 3']] # OR
Usage: static
filter(table, conditions)
- Parameter
-
table
-Array<Array>
the table structure to use as baseconditions
-Array
for records to be kept
- Return
Array<Array>
the changed table
Create Instrances
A new Table
instance can be done by using it’s
Conversion Methods
To convert from and to the different data structures described above, you can use the following 4 methods:
CoffeeScript Code table.fromRecordList recordList
table.fromRecordObject recordObject, idColumn
result = table.toRecordList()
result = table.toRecordObject()
The conversion to record object will loose the name of the first column so it will always get ‘ID’ on back conversion '‘fromRecordObject’ if not defined otherwise.
fromRecordList()
Convert from record list to table structure.
Usage:
fromRecordList(obj)
- Parameter
-
obj
-Array<Object>
record list to read
- Return
Table
class instance itself
toRecordList()
Convert from table structure to record list.
Usage:
toRecordList()
- Return
Array<Object>
record list to read
fromRecordObject()
Convert from record object to table structure.
Usage:
fromRecordObject(obj, idColumn)
- Parameter
-
obj
-Object<Object>
record object to readidColumn
-String
optional title for the id column to be used
- Return
Table
class instance itself
toRecordObject()
Convert from table structure to record object.
Usage:
toRecordObject()
- Return
Object<Object>
record object to read
Access Methods
This methods allows you to easily read and edit the table data in your code.
data
This is the internal storage of the table structure. You may directly access this array of arrays which stores data in rows and columns:
CoffeeScript Code console.log table.data
This may look like:
[ ['ID', 'Name'],
[1, 'one'],
[2, 'two'],
[3, 'three'] ]
field()
This method is used to access cell values or set them.
Examples
Read a cell value:
CoffeeScript Code value = table.field 1, 1
# will result value of field 1/1
value = table.field 1, 'Name'
# do the same but using the column name
And set a new value to a defined cell:
CoffeeScript Code table.field 1, 1, 15.8
# will set value of field 1/1
table.field 1, 'Name', 15.8
# do the same but using the column name
Usage:
field(row, column, value)
- Parameter
-
row
-Integer
number from 1… (0 is the heading)column
-Integer|String
number of column 0… or the name of a columnvalue
- optional new value for the given cell
- Return
- the current (new) value of the given cell or the instance itself if no new value was given
row()
Get or set a complete table row.
Examples
First you may read one row as record:
CoffeeScript Code record = table.row 1
# may return something like {ID: 1, Name: 'one'}
And then you may also overwrite it with a changed version:
CoffeeScript Code table.row 1, {ID: 3, Name: 'three'}
Usage:
row(row, value)
- Parameter
-
row
-Integer
number from 1… (0 is the heading)value
-Array
optional new value for the given row
- Return
- the defined row as object or the inctance if value was given
insert()
Insert multiple rows into the Table.
Examples
CoffeeScript Code table.insert 2, [
[5, 'five']
[6, 'six']
]
If you want to insert record list or record object data you have to convert them first.
Usage:
insert(pos, rows)
- Parameter
-
pos
-Integer
row position from 1… (0 is the heading) use ‘null’ to add at the endrows
-Array|Array<Array>
table rows to add
- Return
Table
the inctance itself
delete()
Delete some rows.
Examples
CoffeeScript Code # delete the second data row:
table.delete 2
# delete the second and third data row:
table.delete 2, 2
Usage:
delete(pos, num)
- Parameter
-
pos
-Integer
row number from 1… (0 is the heading)num
-Integer
optional number of rows to delete (defaults to 0)
- Return
Table
the inctance itself
shift()
Remove the first row as record object from the table. The header will be kept.
Examples
CoffeeScript Code record = table.shift()
# record = {ID: 1, Name: 'one'}
Usage:
shift()
- Return
- the first row as object
unshift()
Add record object to the start of the table.
Examples
CoffeeScript Code table.unshift {id: 0, Name: 'zero'}
Usage:
unshift(record)
- Parameter
-
record
-Object
to add
- Return
Table
the inctance itself
pop()
Remove the last row as record object from the table. The header will be kept.
Examples
CoffeeScript Code record = table.pop()
# record = {ID: 3, Name: 'three'}
Usage:
pop()
- Return
- the last row as object.
push()
Add record object to the end of the table.
Examples
CoffeeScript Code table.push {id: 4, Name: 'four'}
Usage:
push(record)
- Parameter
-
record
-Object
to add
- Return
Object
the just added record
column()
Get a defined column as array.
The column number will start at 0…
Examples
CoffeeScript Code result = table.column 'Name'
# result = ['one', 'two', 'three']
Usage:
column(column, values)
- Parameter
-
column
-Integer|String
the column to exportvalues
-Array
optional values for row 1…
- Return
Array
values for the column fields from row 1… The header name is not included.
columnAdd()
Get a defined column.
Examples
You may only add a column (here as second column - index 1):
CoffeeScript Code table.columnAdd 1, 'DE'
# table.data = [
# [ 'ID', 'DE', 'Name' ]
# [ 1, null, 'one' ]
# [ 2, null, 'two' ]
# [ 3, null, 'three' ]
# ]
Or also add values for this column:
CoffeeScript Code table.columnAdd 1, 'DE', ['eins', 'zwei', 'drei']
# table.data = [
# [ 'ID', 'DE', 'Name' ]
# [ 1, 'eins', 'one' ]
# [ 2, 'zwei', 'two' ]
# [ 3, 'drei', 'three' ]
# ]
Usage:
columnAdd(column, name, values)
- Parameter
-
column
-Integer|String
position there inserting new columnname
-String
of the new columnvalues
-Array
optional values for row 1…
- Return
Table
the instance itself
columnRemove()
Get a defined column.
Examples
This will remove the first column with the ID and keep only the Name column:
CoffeeScript Code table.columnRemove 0
# table = [
# [ 'Name' ]
# [ 'one' ]
# [ 'two' ]
# [ 'three' ]
# ]
Usage:
columnRemove(column)
- Parameter
-
column
-Integer|String
position there deleting column
- Return
Table
instance itself
Join Methods
There are basically two methods of appending. First vertivally by appending the tables below each one. And second vertically by combining the rows.
append()
This may append two tables under each other. The resulting table will have the columns from both of them.
Examples
CoffeeScript Code table.append [
[4, 'four']
[5, 'five']
[6, 'six']
]
# table.data = [
# ['ID', 'Name']
# [1, 'one']
# [2, 'two']
# [3, 'three']
# [4, 'four']
# [5, 'five']
# [6, 'six']
# ]
Usage:
append(table2, ...)
- Parameter
-
table2
-Array<Array>
to append...
-Array<Array>
more tables
- Return
Table
the instance itself
join()
This works like a sql database join and if it is possible better use it within the database because of the performance.
Examples
CoffeeScript Code table.join 'left', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 1, 'one', null ]
# [ 2, 'two', 'zwei' ]
# [ 3, 'three', null ]
# ]
CoffeeScript Code table.join 'right', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 2, 'two', 'zwei' ]
# [ null, 'seven', 'sieben' ]
# ]
CoffeeScript Code table.join 'inner', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 2, 'two', 'zwei' ]
# ]
CoffeeScript Code table.join 'outer', [
['Name', 'DE']
['two', 'zwei']
['seven', 'sieben']
]
# table.data = [
# [ 'ID', 'Name', 'DE' ]
# [ 1, 'one', null ]
# [ 3, 'three', null ]
# [ null, 'seven', 'sieben' ]
# ]
Usage:
join(type, table2, ...)
- Parameter
-
type
-String
type of join like: ‘left’, ‘inner’, ‘right’, ‘outer’table2
-Array<Array>
to join...
-Array<Array>
more tables
- Return
Table
the instance itself
Transform Methods
sort()
Sort the data rows by the specified columns.
Examples
CoffeeScript Code # sort after Name column
table.sort 'Name'
# reverse sort
table.sort '-Name'
# sort after ID then Name
table.sort ['ID', 'Name']
# the same
table.sort 'ID, Name'
Usage:
sort(sort)
- Parameter
-
sort
-String|Array
columns to order by. The sort columns may be number or names as array or comma delimited string. To sort. For reverse order prepend the column with ‘-’.
- Return
Table
the instance itself
reverse()
Reverse the order of all data rows in the table.
Examples
CoffeeScript Code table.reverse()
Usage:
reverse()
- Return
Table
the instance itself
flip()
You may switch the x-axis and y-axis of your table.
Examples
CoffeeScript Code table.flip()
# table.data = [
# [ 'ID', 1, 2, 3 ]
# [ 'Name', 'one', 'two', 'three' ]
# ]
Usage:
flip()
- Return
Table
the instance itself
format()
Format column values.
The format is defined like the validator schema or a user defined function which will be called with the cell value and should return the formatted value.
Examples
CoffeeScript Code table.format
ID:
type: 'percent'
format: '0%'
Name:
type: 'string'
upperCase: 'first'
# table.data = [
# [ 'ID', 'Name' ]
# [ '100%', 'One' ]
# [ '200%', 'Two' ]
# [ '300%', 'Three' ]
# ]
And with custom functions the call should look like:
CoffeeScript Code table.format
Name: (cell) -> cell.toString().toUpperCase()
Usage:
format(formats)
- Parameter
-
formats
-Array|Object
for the columns- array with each columns format
- object with ‘column: format’
- Return
Table
the instance itself
rename()
Rename a column.
Examples
CoffeeScript Code table.rename 'Name', 'EN'
Usage:
rename(col, name)
- Parameter
-
col
-Integer|String
column to renamename
-String
new name for defined column
- Return
Table
the instance itself
Filtering Methods
columns()
Rename multiple columns, reorder them and filter them.
The columns can be defined all using true, meaning to use them in the existing order or with the number or name so a resorting is also possible in one step.
Examples
In the following example only the first two columns are kept and named:
CoffeeScript Code table.columns
ID: true
EN: true
# table.data = [
# [ 'ID', 'EN' ]
# [1, 'one']
# [2, 'two']
# [3, 'three']
# ]
And here the columns are also reordered:
CoffeeScript Code table.columns
EN: 'Name'
ID: 'ID'
# table.data = [
# ['EN', 'ID']
# ['one', 1]
# ['two', 2]
# ['three', 3]
# ]
Usage:
columns(columns)
- Parameter
-
columns
-Object<String>
column name: column to use
- Return
Table
the instance itself
unique()
Remove all duplicate data rows.
Examples
CoffeeScript Code # remove all completely duplicate rows
table.unique()
# remove all rows with duplicate Name column
table.unique 'Name'
Usage:
unique(columns)
- Parameter
-
columns
-Integer|String|Array
to check for uniqueness
- Return
Table
the instance itself
filter()
Filter the rows using specific conditions per column.
The conditions are strings consisting of ’
CoffeeScript Code conditions = ['Name not null', ['Name startsWith a', 'Name startsWith b']]
This results in the following logic:
Name not null
# and
Name startsWith a
# or
Name startsWith b
Examples
CoffeeScript Code table.filter ['ID > 1', 'ID < 8'] # AND
table.filter [['ID < 2', 'ID > 3']] # OR
Usage:
filter(conditions)
- Parameter
-
conditions
-Array
for records to be kept
- Return
Table
the instance itself
Styling
If you use a table instance you may also store meta data in the object which may later be used for styling outside of this module.
Supported in Report:
- ‘align’ on column or sheet with values: ‘left’, ‘center’, ‘right’ (‘left’ is default)
style()
Set or clear style information. To set for a single cel, row, column or the complete sheet.
Examples
CoffeeScript Code # set style for row 0 colummn 1
table.style 0, 1, {align: 'left'}
# the same with a named column
table.style 0, 'Name', {align: 'left'}
# and remove the styles
table.style 0, 1, null
# set style for row 1
table.style 1, null, {align: 'left'}
# and remove the styles
table.style 1, null, null
# set style for column 1
table.style null, 1, {align: 'left'}
# and remove the styles
table.style null, 1, null
# set style for the sheets
table.style null, null, {align: 'left'}
# and remove the styles
table.style null, null, null
# set style for user defined range
table.style 1, 0, 3, 2, {align: 'left'}
# and remove the styles
table.style 1, 0, 3, 2, null
Usage:
style(from-row, from-col, to-row, to-col, style)
- Parameter
-
from-row
-Integer
row numberfrom-col
-Integer|String
column number or nameto-row
-Integer
optional row numberto-col
-Integer|String
optional column number or namestyle
-Object
optional settings to store or null to delete all
- Return
Table
the instance itself
getMeta()
This will calculate the resulting settings of the combinations of the above.
To set for a single cel, row, column or the complete sheet:
Examples
CoffeeScript Code # get styles for cell
style = table.getMeta 0, 1
# style = {align: 'left'}
# get styles for row
style = table.getMeta 0
# get styles for column
style = table.getMeta null, 1
# get styles for sheet
style = table.getMeta()
Usage:
getMeta(row, col)
- Parameter
-
row
-Integer
number or null for all rowscol
-Integer|String
column number or name, null for all columns
- Return
Object
the combined style settings