| javascript_components

# Class: Bs_SpreadSheet Source Location: /components/spreadsheet/Bs_SpreadSheet.class.js.php
### Class Overview
Bs_SpreadSheet.class.js - clientside spreadsheet editor, excel-like. #### Author(s): andrej arn <at blueshoes dot org> #### Version: 3.1 (2003/11/04) #### Copyright: blueshoes.org | ### Variables $buttonsPath $debug $defaultCellHeight $defaultCellWidth $editorI $editorJ $firstColTitle $firstRowTitle $mayUseAlign $mayUseClipboard $mayUseFormat $mayUseWysiwyg $numCols $numRows $objectName $returnType $sheedHeight $sheetWidth $showLineNumbers $useToolbar $_currentCellLastValue | ### Methods addCol addRow calculateCellHeight calculateCellSizes calculateCellWidth cellSelect draw editCellEnd editCellStart emptyValue exportDataToCsv formatAlign formatBold formatItalic formatUnderline getCellCaption getCol getNumCols getNumRows getRow init onGlobalPaste onPaste pasteValue removeCol removeContent removeRow save setDrawStyle setMousePointer setValue sortAsc sortDesc toHtml typing updateDataFromFields _readFromClipboard
### Inherited Variables | ### Inherited Methods
### Class Details [line 53] Bs_SpreadSheet.class.js - clientside spreadsheet editor, excel-like. makes tables/cvs data editable by web users. website for this component: http://www.blueshoes.org/en/javascript/spreadsheet/ developed and tested using ie6. mozilla works as well but not everything. check the web page. Includes (+Dependences):

    1     /_bsJavascript/core/html/Bs_HtmlUtil.lib.js
    2         /_bsJavascript/core/lang/Bs_Array.class.js
    3         /_bsJavascript/core/util/Bs_String.lib.js
    4         /_bsJavascript/core/util/Bs_CsvUtil.class.js
    5         /_bsJavascript/core/lang/Bs_Misc.lib.js
    6         /_bsJavascript/components/spreadsheet/Bs_SpreadSheet.class.js
    7         /_bsJavascript/components/spreadsheet/Bs_SpreadSheet.inc.js
    8         /_bsJavascript/components/toolbar/Bs_ButtonBar.class.js
    9         /_bsJavascript/components/toolbar/Bs_Button.class.js
#### Tags:
copyright: | blueshoes.org
author: | andrej arn <at blueshoes dot org>
version: | 3.1 (2003/11/04)
[ Top ] ### Class Variables #### $buttonsPath = '/_bsImages/buttons/' [line 292] the image path for the button toolbar. #### Tags:
var: | buttonsPath
access: | public
Type: | string
[ Top ] #### $debug = false [line 68] are we in debug mode or not? default is false. #### Tags:
var: | debug
access: | public
Type: | bool
[ Top ] #### $defaultCellHeight = 20 [line 240] default cell height in pixels. default is 20. #### Tags:
var: | defaultCellHeight
see: | _cellHeight
access: | public
Type: | int
[ Top ] #### $defaultCellWidth = 80 [line 223] default cell width in pixels. default is 80. #### Tags:
var: | defaultCellWidth
see: | _cellWidth
access: | public
Type: | int
[ Top ] #### $editorI = [line 272] don't recall what this was for, but it's needed.
Type: | mixed
[ Top ] #### $editorJ = [line 276] don't recall what this was for, but it's needed.
Type: | mixed
[ Top ] #### $firstColTitle = false [line 95] tells if the first col is a title col. this is important for sorting. #### Tags:
var: | firstColTitle (default is false)
see: | Bs_SpreadSheet::$firstRowTitle
access: | public
Type: | bool
[ Top ] #### $firstRowTitle = false [line 86] tells if the first row is a title row. this is important for sorting. #### Tags:
var: | firstRowTitle (default is false)
see: | Bs_SpreadSheet::$firstColTitle
access: | public
Type: | bool
[ Top ] #### $mayUseAlign = true [line 123] if the cell alignments may be specified (left, center, right). default is true. #### Tags:
var: | mayUseWysiwyg
access: | public
Type: | bool
[ Top ] #### $mayUseClipboard = true [line 109] if the clipboard can be used, by buttons and shortcuts. #### Tags:
var: | mayUseClipboard
access: | public
Type: | bool
[ Top ] #### $mayUseFormat = true [line 116] if cell formatting may be used (bold, italic, underline). default is true. #### Tags:
var: | mayUseFormat
access: | public
Type: | bool
[ Top ] #### $mayUseWysiwyg = true [line 130] if the cell wysiwyg editor may be used. default is true. #### Tags:
var: | mayUseWysiwyg
access: | public
Type: | bool
[ Top ] #### $numCols = 6 [line 154] the initial number of columns. if the used data (in the constructor) has more, then there are more. set to 0 if you don't want this feature. #### Tags:
var: | numCols
since: | bs4.4
see: | var numRows
access: | public
Type: | int
[ Top ] #### $numRows = 10 [line 165] the initial number of rows. if the used data (in the constructor) has more, then there are more. set to 0 if you don't want this feature. #### Tags:
var: | numRows
since: | bs4.4
see: | var numCols
access: | public
Type: | int
[ Top ] #### $objectName = [line 61] the name of this object instance that is in the global scope. absolutely needed. #### Tags:
var: | objectName
access: | public
Type: | string
[ Top ] #### $returnType = 'array' [line 194] the return type. :) 'array' => javascript array. that's the default. 'csv' => string, comma separated values à la excel #### Tags:
var: | returnType
access: | public
Type: | string
[ Top ] #### $sheedHeight = 230 [line 267] the height of the sheet area in pixels. #### Tags:
var: | sheedHeight
since: | bs4.4
see: | var sheetWidth
access: | public
Type: | int
[ Top ] #### $sheetWidth = 450 [line 258] the width of the sheet area in pixels. #### Tags:
var: | sheetWidth
since: | bs4.4
see: | var sheedHeight
access: | public
Type: | int
[ Top ] #### $showLineNumbers = true [line 77] if line numbers should be displayed or not. default is true. #### Tags:
var: | showLineNumbers
todo: | implement this option
access: | public
Type: | bool
[ Top ] #### $useToolbar = true [line 102] if the button bar should be used. default is true. #### Tags:
access: | public
Type: | bool
[ Top ] #### $_currentCellLastValue = [line 215] need in case the user cancels the edit mode to write it back. #### Tags:
var: | _currentCellLastValue
Type: | string
[ Top ] ### Class Methods ### method addCol [line 345]
`void addCol( mixed pos, bool noRedraw)`
add a col into the data array param pos: int position, value from 0-n (yes it may be 0, starts at 0 not 1.) or bool true (left of current cell) false (right of current cell) or nothing/null/undefined => at the end #### Tags:
access: | public
#### Parameters:
mixed | pos | pos (see above)
bool | noRedraw | noRedraw (in case you want to do more stuff, and then redraw yourself.)
[ Top ] ### method addRow [line 414]
`void addRow( mixed pos, bool noRedraw)`
add a row into the data array param pos: int position, value from 0-n (yes it may be 0, starts at 0 not 1.) or bool true (above current cell) false (below current cell) or nothing/null/undefined => at the end #### Tags:
access: | public
#### Parameters:
mixed | pos | pos (see above)
bool | noRedraw | noRedraw (in case you want to do more stuff, and then redraw yourself.)
[ Top ] ### method calculateCellHeight [line 1529]
`void calculateCellHeight( )`
calculates the height for each row. #### Tags:
see: | this._cellHeight
access: | public
[ Top ] ### method calculateCellSizes [line 1567]
`void calculateCellSizes( )`
!!! not used [anymore?] !!! [ Top ] ### method calculateCellWidth [line 1506]
`void calculateCellWidth( )`
calculates the width for each column. #### Tags:
see: | this._cellWidth
access: | public
[ Top ] ### method cellSelect [line 1051]
`void cellSelect( object cell cell)`
selects a new cell. deselects the curently selected cell. #### Tags:
access: | public
#### Parameters:
object cell | cell |
[ Top ] ### method draw [line 631]
`void draw( )`
[re]draws the editor. #### Tags:
access: | public
[ Top ] ### method editCellEnd [line 1151]
`void editCellEnd( object cell cell)`
stops edit mode for the given cell, goes back into active mode. #### Tags:
access: | public
#### Parameters:
object cell | cell |
[ Top ] ### method editCellStart [line 1119]
`void editCellStart( object cell cell)`
makes the given cell the active one, starts edit mode. #### Tags:
access: | public
#### Parameters:
object cell | cell |
[ Top ] ### method emptyValue [line 1607]
`void emptyValue( int row, int col)`
removes the content of a cell, col, row or the whole table. if row is NaN then the whole row is emptied. same for col. currently only works if both row and col are given. #### Tags:
todo: | read above
access: | public
#### Parameters:
int | row | row
int | col | col
[ Top ] ### method exportDataToCsv [line 607]
`string exportDataToCsv( )`
exports the data, and only the data (no style information) to cvs format. #### Tags:
since: | bs4.4
access: | public
[ Top ] ### method formatAlign [line 1719]
`void formatAlign( bool left, bool center, bool right)`
formats the alignment of the current cell. one or none of the given params may be true. #### Tags:
access: | public
#### Parameters:
bool | left | left
bool | center | center
bool | right | right
[ Top ] ### method formatBold [line 1652]
`void formatBold( bool val)`
formats the currently selected cell bold. #### Tags:
access: | public
#### Parameters:
bool | val | val (true = bold, false = not bold)
[ Top ] ### method formatItalic [line 1673]
`void formatItalic( bool val)`
formats the currently selected cell italic. #### Tags:
access: | public
#### Parameters:
bool | val | val (true = italic, false = not italic)
[ Top ] ### method formatUnderline [line 1694]
`void formatUnderline( bool val)`
formats the currently selected cell underline. #### Tags:
access: | public
#### Parameters:
bool | val | val (true = underline, false = not underline)
[ Top ] ### method getCellCaption [line 1472]
`int getCellCaption( string cellId)`
returns a string like C5 or B7. #### Tags:
access: | public
#### Parameters:
string | cellId | cellId
[ Top ] ### method getCol [line 1457]
`int getCol( string cellName)`
returns the col number of the cell with the given name. starts at 0, not 1. #### Tags:
return: | (0-n)
#### Parameters:
string | cellName | cellName
[ Top ] ### method getNumCols [line 1495]
`int getNumCols( )`
returns the number of cols. #### Tags:
access: | public
[ Top ] ### method getNumRows [line 1482]
`int getNumRows( )`
returns the number of rows. #### Tags:
access: | public
[ Top ] ### method getRow [line 1440]
`int getRow( string cellName)`
returns the row number of the cell with the given name. starts at 0, not 1. #### Tags:
return: | (0-n)
#### Parameters:
string | cellName | cellName
[ Top ] ### method init [line 557]
`void init( array data, string drawTagId, string callbackFunction)`
inits the editor with the given data. calls draw(). #### Tags:
access: | public
#### Parameters:
array | data | data (the 2 dimensional data vector, see this._importData(), some documentation would be nice...)
string | drawTagId | drawTagId (id of the tag we use to draw the whole spreadsheet.)
string | callbackFunction | callbackFunction (the js function to call when setting back the data to the caller)
[ Top ] ### method onGlobalPaste [line 1365]
`void onGlobalPaste( element cell)`
fires on a paste on a cell. by hitting ctrl-v or clicking the paste button. #### Parameters:
element | cell | cell
[ Top ] ### method onPaste [line 1346]
`void onPaste( mixed cell)`
[ Top ] ### method pasteValue [line 1397]
`void pasteValue( string value, element cell)`
#### Tags:
access: | public
#### Parameters:
string | value | value
element | cell | cell
[ Top ] ### method removeCol [line 482]
`void removeCol( int pos)`
remove a col from the data array param pos: if not given (not numeric) then the col of the currently selected cell will be removed. #### Tags:
access: | public
#### Parameters:
int | pos | pos (position, value from 0-n (yes it may be 0))
[ Top ] ### method removeContent [line 1427]
`void removeContent( object cell cell)`
clears the content of the given cell. #### Tags:
todo: | i think this method exists twice with different names and code.
#### Parameters:
object cell | cell |
[ Top ] ### method removeRow [line 520]
`void removeRow( int pos)`
remove a row from the data array param pos: if not given (not numeric) then the row of the currently selected cell will be removed. #### Parameters:
int | pos | pos (position, value from 0-n (yes it may be 0))
[ Top ] ### method save [line 1020]
`void save( )`
set the data back to the caller. #### Tags:
access: | public
[ Top ] ### method setDrawStyle [line 1008]
`void setDrawStyle( string drawStyle)`
sets the draw style. redraws the editor. #### Parameters:
string | drawStyle | drawStyle
[ Top ] ### method setMousePointer [line 302]
`void setMousePointer( bool work)`
changes the cursor icon to something else. i think this one did not work like i wanted it to, so it's not used. (i wanted to set the sandbox while the computer is working...) #### Tags:
access: | public
#### Parameters:
bool | work | work
[ Top ] ### method setValue [line 1620]
`void setValue( string val, int row, int col, bool noRedraw)`
sets the given value for the given cell. #### Tags:
access: | public
#### Parameters:
string | val | val
int | row | row (0-n)
int | col | col (0-n)
bool | noRedraw | noRedraw (in case you want to do more stuff at once, and then redraw yourself.)
[ Top ] ### method sortAsc [line 1811]
`void sortAsc( )`
sorts the sheet in ascending order on the col of the currently selected cell. #### Tags:
see: | Bs_SpreadSheet::sortDesc()
access: | public
[ Top ] ### method sortDesc [line 1826]
`void sortDesc( )`
sorts the sheet in descending order on the col of the currently selected cell. #### Tags:
see: | Bs_SpreadSheet::sortAsc()
access: | public
[ Top ] ### method toHtml [line 1885]
`string toHtml( bool withStyle)`
exports the data table as html output. #### Tags:
return: | (html)
access: | public
#### Parameters:
bool | withStyle | withStyle (default is false)
[ Top ] ### method typing [line 1201]
`bool typing( )`
handles the keydown event. #### Tags:
return: | (true to continue handling the event, false to stop.)
[ Top ] ### method updateDataFromFields [line 985]
`void updateDataFromFields( )`
walks through the structure of the data array and replaces all values with the new ones that are currently set in the page/form by the user. #### Tags:
access: | public
[ Top ] ### method _readFromClipboard [line 1903]
`void _readFromClipboard( mixed key)`
[ Top ] Documentation generated on Mon, 29 Dec 2003 22:18:31 +0100 by phpDocumentor 1.2.3