Documentation

Examples

jExcel quick reference

Methods

MethodDescription
getData: Get the full or partial table data
@Param boolan onlyHighlighedCells - Get only highlighted cells
$('#my').jexcel('getData', false);
setData: Update the table data
@Param json newData - New json data, null will reload what is in memory.
@Param boolean ignoreSpare - ignore configuration of minimal spareColumn/spareRows
$('#my').jexcel('setData', [json], false);
insertColumn: add a new column
@Param integer numberOfColumns - Number of columns should be added
@Param string headerTitle - Header title
$('#my').jexcel('insertColumn', 1, { header:'Title' });
deleteColumn: remove column by number
@Param integer columnNumber - Which column should be excluded starting on zero
$('#my').jexcel('deleteColumn', 1);
insertRow: add a new row
@Param integer numberOfRows - Number of rows should be added
$('#my').jexcel('insertRow', 1);
deleteRow: remove row by number
@Param integer rowNumber - Which row should be excluded starting on zero
$('#my').jexcel('deleteRow', 1);
getHeader: get the current header by column number
@Param integer columnNumber - Column number starting on zero
$('#my').jexcel('getHeader', 2);
setHeader: change header by column
@Param integer columnNumber - column number starting on zero
@Param string columnTitle - New header title
$('#my').jexcel('setHeader', 1, 'Title');
getWidth: get the current column width
@Param integer columnNumber - column number starting on zero
$('#my').jexcel('getWidth', 2);
setWidth: change column width
@Param integer columnNumber - column number starting on zero
@Param string newColumnWidth - New column width
$('#my').jexcel('setWidth', 1, 100);
orderBy: will reorder a column asc or desc
@Param integer columnNumber - column number starting on zero
@Param smallint sortType - Zero will toggle current option, one for desc, two for asc
$('#my').jexcel('orderBy', 2);
getValue: get current cell value
@Param mixed cellIdent - str compatible with excel, or as object.
$('#my').jexcel('getValue', 'A1');
setValue: change the cell value
@Param mixed cellIdent - str compatible with excel, or as object.
@Param string Value - new value for the cell
$('#my').jexcel('setValue', 'A1');
updateSelection: select cells
@Param object startCell - cell object
@Param object endCell - cell object
@Param boolean ignoreEvents - ignore onselection event
$('#my').jexcel('updateSelection', [cell], [cell], true);
download: get the current data as a CSV file.
@Param none
$('#my').jexcel('download');

Working example


Events

Eventdescription
onload This method is called when the method setData
onbeforechange Before a column value is changed.
onchange After a column value is changed.
onafterchange After all change events is performed.
oninsertrow After a new row is inserted.
ondeleterow After a row is excluded.
oninsertcolumn After a new column is inserted.
ondeletecolumn After a column is excluded.
onselection On the selection is changed.
onsort After a colum is sorted.
onresize After a colum is resized.
onmoverow After a row is moved to a new position.
onfocus On table focus
onblur On table blur

Example on handling events on jExcel


Initialization parameters

Parameterdescription
columns Column type, dropdown options, text wrapping, marking, etc.
colHeaders Column header titles
colWidths Column widths: width in px.
colAlignments Column alignments: left, right, center.
colHeaderClasses Column custom CSS classes
defaultColWidth Default width for a new column
minSpareRows Minimum number of spare rows
minSpareCols Minimum number of spare cols
minDimensions Minimum table dimensions: [cols,rows]
contextMenu Context menu content: function() { return customMenu }
columnSorting Allow column sorting: bool
columnResize Allow column resizing: bool
rowDrag Allow row dragging: bool
editable Allow table edition: bool
allowInsertRow Allow insert a new row: bool
allowManualInsertRow Allow user to insert a new row: bool
allowInsertColumn Allow insert a new column: bool
allowManualInsertColumn Allow user to create a new column: bool
allowDeleteRow Allow delete a row: bool
allowDeleteColumn Allow delete a column: bool
wordWrap Global text wrapping: bool
csvFileName CSV default file name: string
selectionCopy Allow selection copy: bool

Buy me a beer?