SpreadSheet control is extremelly fast and small Excell like control, developed in Assembler.
(See SpreadSheet.png)
SpreadSheet | SpreadSheet control is extremelly fast and small Excell like control, developed in Assembler. |
Add | Add control to the Gui |
BlankCell | Erase the cell. |
CreateCombo | Creates COMBOBOX cell type. |
ConvertDate | Converts date from / to integer. |
DeleteCell | Delete cell. |
DeleteCol | Delete column. |
ExpandCell | Expand a cell to cover more than one cell. |
GetCell | Get the cell parameters. |
GetCellArray | Get all cell parameters into array. |
GetCellBlob | Returns pointer to the current cell BLOB. |
GetCellData | Get the cell data. |
GetCellRect | Get the current cells rect in active splitt. |
GetCellText | Get cell text |
GetCellType | Get cell data type |
GetColCount | Get number of columns |
GetColWidth | Get column width. |
GetCurrentCell | Get current cell in active window. |
GetCurrentCol | Get current column in active window. |
GetCurrentRow | Get current row in active window. |
GetCurrentWin | Get active splitt window. |
GetDateFormat | Get date format. |
GetLockCol | Get lock cols in active splitt. |
GetLockRow | Get lock rows in active splitt. |
GetMultiSel | Get multiselection. |
GetRowCount | Get number of rows. |
GetRowHeight | Returns row height. |
ImportLine | Import a line of data. |
InsertCol | Insert column. |
InsertRow | Insert row. |
LoadFile | Load a file. |
NewSheet | Clears the sheet. |
ReCalc | Recalculates the sheet. |
Redraw | Redraw the control. |
SaveFile | Save a file. |
ScrollCell | Scrolls current cell into view. |
SetCell | Set content of the cell. |
SetCellData | Set the data of the cell. |
SetCellBLOB | Set the cell binary data. |
SetCellString | Set the text of the selected cell. |
SetColWidth | Set column width. |
SetCurrentCell | Set current cell in the active window. |
SetCurrentWin | Set active splitt window. |
SetDateFormat | Set date format. |
SetColCount | Set number of columns. |
SetFont | Set font. |
SetGlobal | Set all global parameters for the control. |
SetGlobalFields | Set individual global parameters for the control. |
SetLockCol | Lock columns in active split. |
SetLockRow | Lock rows in active split. |
SetMultiSel | Set multiselection |
SetRowCount | Set number of rows. |
SetRowHeight | Set row height. |
SplittHor | Create horizontal splitt in current splitt at current row. |
SplittVer | Create vertical splitt in current splitt at current col. |
SplittClose | Close the current splitt. |
SplittSync | Synchronizes a splitt window with it’s parent. |
Formulas | |
Graphs | |
Examples | |
Known Bugs | |
About |
SS_Add( HParent, X, Y, W, H, Style = "", Handler = "", DllPath = "" )
Add control to the Gui
HParent | Parent’s handle. |
X..H | Control coordinates. |
Style | White separated list of control styles. |
Handler | Notification handler, optional. |
DllPath | Path to the dll, by default look at the working folder. |
VSCROLL HSCROLL STATUS GRIDLINES ROWSELECT CELLEDIT GRIDMODE COLSIZE ROWSIZE WINSIZE MULTISELECT
result := Handler(HCtrl, Event, EArg, Col, Row)
HCtrl | Handle of the speradsheet control that sends the notification. |
Event | Event that ocured. Can be S (select), EB (before edit), EA (after edit), UB (before update), UA (after update), C (click) and D (draw) |
EArg | Event argument. Depends on event. See below. |
Col | Column of the associated cell. |
Row | Row of the associated cell. |
result | Handler result, depends on event. See bellow. |
Handler’s EArg parameter is specific to each event:
S | Current splitt window number. Return 1 to prevent selection. |
EA | User input. Return 1 to discard user input. |
C | B (Button) or H (Hyperlink). Return value isn’t used. |
EB,UB,UB | Empty (argument isn’t used). Return value isn’t used. |
D | Pointer to DRAWITEMSTRUCT. See http://msdn.microsoft.com |
Control’s handle.
SS_ConvertDate( hCtrl, Date, RefreshFormat = false )
Converts date from / to integer.
Date | Integer or textual representation of the date. |
RefreshFormat | Set to TRUE to refresh control’s date format that is stored internaly on first call. |
If Date is integer the return value is the date string, otherwise the retun value is integer representation of the date.
SS_DeleteCell( hCtrl, Col = "", Row = "" )
Delete cell.
Its misterious to me what is the difference between this one and BlankCell.
SS_GetCell( hCtrl, Col, Row, pQ, ByRef o1 = "", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "" )
Get the cell parameters.
Col, Row | Cell coordinates. If set to empty current cell coordinates will be used. |
pQ | Query parameter. See SetCell for the list of possible cell parameters (txt, data, w, h, bg, fg, type, state, txtal, imgal, fnt) |
o1 .. o5 | Reference to variables to receive output in order specified in pQ parameter. |
o1, so you don’t need to use reference variables to grab only 1 field i.e. state := SS_GetCell(hctrl, 1,1, “state”).
SS_GetCellArray( hCtrl, V, Col = "", Row = "" )
Get all cell parameters into array.
V | Array prefix. The array is used to return data back. See SetCell for the list of possible cell parameters. |
Col, Row | Cell coordinates. If omited current cell coordinates will be used. |
To get individual fields, its faster to use GetCell. Also, this function creates global variables.
SS_GetCellText( hCtrl, Col = "", Row = "" )
Get cell text
Col, Row | Coordinates of the cell. If omited, current cell will be used. |
This function retrieves any kind of text from all types of cells, no matter the internal representation. For ComboBox selected item will be returned and for CheckBox 1 or 0.
SS_SetCell( hCtrl, Col = "", Row = "", o1 = "", o2 = "", o3 = "", o4 = "", o5 = "", o6 = "", o7 = "", o8 = "", o9 = "", o10 = "", o11 = "" )
Set content of the cell.
Col, Row | Cell coordinates. |
o1 .. o11 | Named parameters. |
type | Type of the cell. See bellow for list of types. You will generally use type when setting up cells initially and omit it when changing existing cells. |
w, h | Width, height of the cell. |
bg, fg | Background, foreground color. |
state | Cell state. |
txtal | Text alignment and decimals. See aligment section for list of kewords. Use number to set FLOAT precision (1-12, all, sci). |
imgal | Image alignment and imagelist/control index . |
fnt | Cell font index (0-15). |
txt | String (TEXT,CHECKBOX,*HDR), Number (INTEGER), hwndCombo (COMBOBOX), Formula Definition (FORMULA), Graph Definition (GRAPH) |
data | 0-based selected index, 0 by default (COMBOBOX), 1|0 (CHECKBOX), size (OVERDRAWBLOB, return) |
BUTTON | The cell contains button. Can be combined with TEXT or TEXTMULTILINE. |
WIDEBUTTON | The cell will be entirely covered by button. Can be combined with TEXT or TEXTMULTILINE. |
DATE | Can be combined with INTEGER. |
FORCETYPE | The cell will preserve its type when edited. Can be combined with TEXT, INTEGER, FLOAT, TEXTMULTILINE, BUTTON, WIDEBUTTON or HYPERLINK. |
FIXEDSIZE | Will force a 15 by 15 pixel image. To be combined with BUTTON, CHECKBOX or COMBOBOX. Can be combined with BUTTON, CHECKBOX or COMBOBOX . |
LOCKED | Cell is locked for editing. |
HIDDEN | Cell content is not displayed. |
REDRAW | Cell is being redrawn. |
RECALC | Cell is being recalculated. |
ERROR | There are 4 error states: ERROR DIV0 UNDERFLOW OVERFLOW. |
LEFT RIGHT MIDDLE | X aligments. |
TOP CENTER BOTTOM | Y aligments. |
AUTO | Text left middle, numbers right middle. |
GLOBAL | If you omit aligment attribute, this one will be used. |
SS_SetGlobal( hCtrl, g, cell, colhdr, rowhdr, winhdr )
Set all global parameters for the control.
g | Global formating array base name. |
cell | Cell formatting array base name. |
colhdr | Column header formatting array base name. |
rowhdr | Row header formatting array base name. |
winhdr | Window header formatting array base name. |
colhdrbtn | Column header button. |
rowhdrbtn | Row header button. |
winhdrbtn | Win header button. |
lockcol | Back color of locked cell. |
hdrgrdcol | Header grid color. |
grdcol | Cell grid color. |
bcknfcol | Back color of active cell, lost focus. |
txtnfcol | Text color of active cell, lost focus. |
bckfocol | Back color of active cell, has focus. |
txtfocol | Text color of active cell, has focus. |
ncols | Number of columns, 0-600, by default 255. |
nrows | Number of rows, 0-65000, by default 255. |
ghdrwt | Header width. |
ghdrht | Header height. |
gcellw | Cell width. |
gcellht | Cell height. |
bg | Background color. |
fg | Foreground color. |
imgal | Image align. |
txtal | Text align. |
fnt | Font index. |
tpe | Control type. |
SS_SetGlobalFields( hCtrl, Fields, v1 = "", v2 = "", v3 = "", v4 = "", v5 = "", v6 = "", v7 = "" )
Set individual global parameters for the control.
fields | White space separated list of field names to set. |
v1 .. v7 | Field values, respecting the order of names in fields argument. |
SS_SetGlobalFields(hCtrl, "nrows ncols", 2, 2) SS_SetGlobalFields(hCtrl, "cell_txtal", "RIGHT MIDDLE")
Type Example Description --------------------------------------------------------------------------------------------------- And, Or, Xor AA1>=0 And AA2<=0 Logical operators <, <=, =, >=, >, <> AA1>=5.5 Compare operators +, -, *, / ((AA1+AA2)/2-3.5)*4 Basic math operators x^y AA1^3.5 x to the power of y Sum(r1:r2) Sum(AA1:AC6) Sum of all cells in an area Cnt(r1:r2) Cnt(AA1:AA5) Number of cells in an area that contains a value Avg(r1:r2) Avg(AB1:AB6) Average value of an area Min(r1:r2) Min(AA1:AA7) Returns smallest number in an area Max(r1:r2) Max(AA1:AB3) Returns largest number in an area Var(r1:r2) Var(AB1:AC6) The variance of an area Std(r1:r2) Std(AB1:AB6) The standard deviation of an area Sqt(num) Sqt(AA1+AA2) Sqear root Sin(num) Sin(AA5) Sine of an angle in radians Cos(num) Cos(PI()/8) Cosine of an angle in radians Tan(num) Tan(Rad(45)) Tangent of an angle in radians Rad(num) Rad(45) Converts grades to radians PI() PI()/4 Returns PI IIf(Cnd,TP,FP) IIf(AA1=0,AA2,AA3) IIf(Condition,TruePart,FalsePart) On(val,num[,num[,num...]]) On(AA1,AA2,AA3,AA4) Depending on val, return num If val<=0, return first num If val>=number of num, return last num Abs(num) Abs(AA5-7) Absolute. Returns absolute value of num Sgn(num) Sgn(AA5) Sign. Returns -1, 0 or +1 Int(num) Int(AA5) Integer. Returns integer value of num Log(num) Log(AA5) Logarithm to base 10 Ln(num) Ln(e()) Natural Logarithm e() e()^AA5 Returns e Asin(num) Asin(AA4) Inverse Sine Acos(num) Acos(AA3) Inverse Cosine Atan(num) Atan(AA1) Inverse Tangent Grd(num) Grd(PI()/4) Converts radians to grades Rgb(num,num,num) Rgb(255,0,0) Converts red, green, blue to color x() Sin(x()) x value used in calculating graphs fx() math functions @(rc,rr) @(-1,2) Relative cell reference CDate(str) CDate("2008-01-01") Converts a date string to days since 1601-01-01
Type Dscription --------------------------------------------------------------------------------------------------- ####Ref Circular reference or reference to cell with error condition ####Err Meaning depends on function ####Div Division by zero ####Ovf Overflow ####Unf Underflow
Grp( [T], X, Y, fx1 | gx1, fx2 | gx2, ...) ;no spaces allowed
T(xp,yp,Orientation,Color,”Text” ) | Text (max 16) |
X,Y(xMin,xMax,xOrigo,xStep,Color,”Text”) | X and Y axis (max 1) |
fx(function,xStep,Color,”Text”) | Graph from math function (max 16) |
gx(r1:r2,Color,”Text”) | Graph from cell values (max 16) |
Bad graph definitions will burn CPU or crash application. Even single space more in Grp syntax will do that, and you will have to kill the AutoHotKey.exe using task manager.
#Singleinstance, force Gui, +LastFound +ToolWindow hwnd := WinExist() hCtrl := SS_Add(hwnd, 0, 0, 300, 400, "VSCROLL GRIDMODE CELLEDIT ROWSIZE COLSIZE ROWSELECT") SS_SetRowHeight(hCtrl) SS_SetColCount(hCtrl, 2) SS_SetRowCount(hCtrl, 8) SS_SetColWidth(hCtrl, 1, 148) SS_SetColWidth(hCtrl, 2, 145) SS_SetGlobalFields(hCtrl, "cell_txtal", "CENTER MIDDLE") hCombo := SS_CreateCombo(hCtrl, "item1|item2|item3|item4") SS_SetCell(hCtrl, 1, 1, "type=TEXT", "txt=Caption", "bg=0xFF", "fg=0xFFFFFF") SS_SetCell(hCtrl, 2, 1, "type=FORCETEXT") SS_SetCell(hCtrl, 1, 2, "type=TEXT", "txt=Style", "bg=0xFF", "fg=0xFFFFFF") SS_SetCell(hCtrl, 2, 2, "type=COMBOBOX", "txt=" hCombo, "data=1", "imgal=RIGHT", "txtal=CENTER") ;select 2nd item SS_SetCell(hCtrl, 1, 3, "type=TEXT", "txt=Anchor", "bg=0xFF", "fg=0xFFFFFF") SS_SetCell(hCtrl, 2, 3, "type=BUTTON TEXT", "txt=w0.5 h", "imgal=RIGHT", "txtal=CENTER") SS_SetCell(hCtrl, 1, 4, "type=TEXT", "txt=Visible", "bg=0xFF", "fg=0xFFFFFF") SS_SetCell(hCtrl, 2, 4, "type=CHECKBOX", "data=1", "imgal=CENTER") SS_SetCell(hCtrl, 1, 6, "type=TEXT", "txt=Help", "bg=0xFFFF", "fg=-1") SS_SetCell(hCtrl, 2, 6, "type=HYPERLINK", "txt=www.autohotkey.com", "txtal=CENTER") SS_SetCell(hCtrl, 1, 8, "type=WIDEBUTTON TEXT", "Txt=Wide &Button", "txtal=CENTER") Gui, Show, w300 h150 return
SS_GetCellArray(hCtrl, "cell") ;"cell" name of pseudo array holding the data, use selected cell msg = (LTrim Text = %cell_txt% Data = %cell_data% State = %cell_hState% bg = %cell_bg% fg = %cell_fg% txtal = %cell_htxtal% imgal = %cell_himgal% fnt = %cell_fnt% type = %cell_Type% ) msgbox %msg%
;header and cell defaults h_bg := c_bg := 0xAAAAAA h_txtal := c_txtal := "CENTER MIDDLE" h_fg := 0xFF0000 h_fnt := 2 g_ncols := 100 ;number of columngs g_nrows := 100 ;number of rows g_colhdrbtn := 0 ;button sytle col hdr g_rowhdrbtn := 0 ;button style row hdr g_winhdrbtn := 0 ;button style win hdr g_lockcol := 0xAAAAAA ;Back color of locked cell g_hdrgrdcol := 0xFF00FF ;Header grid color g_grdcol := 0xFFFFFF ;Cell grid color g_bcknfcol := 0xCCCCCC ;Back color of active cell, lost focus g_txtnfcol := 1 ;Text color of active cell, lost focus g_bckfocol := 0xFFFF ;Back color of active cell, has focus g_txtfocol := 0 ;Text color of active cell, has focus g_ghdrwt := 25 ;header width g_ghdrht := 25 ;header height g_gcellw := 50 ;cell width g_gcellht := 50 ;cell height SS_SetGlobal(hCtrl, "g", "c", "h", "h", "h")
;formula Gui, +LastFound hwnd := WinExist() hCtrl := SS_Add(hwnd, 0, 25, 552, 477, "CELLEDIT STATUS") SS_SetCell(hCTrl, 1, 1, "txt= x =", "type=TEXT", "txtal=CENTER", "fnt=1") SS_SetCell(hCTrl, 1, 2, "txt= y =", "type=TEXT", "txtal=CENTER", "fnt=1") SS_SetCell(hCTrl, 1, 3, "txt=x+y =", "type=TEXT", "txtal=CENTER", "fnt=1") SS_SetCell(hCtrl, 2, 1, "type=INTEGER", "txt=90", "fnt=1", "txtal=LEFT") SS_SetCell(hCtrl, 2, 2, "type=INTEGER", "txt=20", "fnt=1", "txtal=LEFT" ) SS_SetCell(hCtrl, 2, 3, "type=FORMULA", "txt=AB1+AB2", "txtal=LEFT") SS_ReCalc(hCtrl) Gui, Show, w550 h500, SpreadSheet return
Gui, +LastFound hwnd := WinExist() hCtrl := SS_Add(hwnd, 0, 25, 552, 477) graph = (LTrim Join Grp( T(-1,0,0,Rgb(0,0,0),"Graph Demo"), X(0,PI()*4,0,1,Rgb(0,0,255),"x-axi), Y(-1.1,1.1,0,0.5,Rgb(255,0,0),"y-axs"is"), gx(AJ1:AJ13,Rgb(0,0,0),"Cell values"), fx(Sin(x()),0.1,Rgb(255,0,255),"Sin(x)"), fx(x()^3-x()^2-x(),0.1,Rgb(0,128,0),"x^3-x^2-x")) ) SS_SetCell(hCtrl, 1, 1, "type=GRAPH", "txt=" graph, "bg=0x0D0FFFF") SS_ExpandCell(hCtrl, 1, 1, 6, 15) Gui, Show, w550 h500, SpreadSheet return
Add control to the Gui
SS_Add( HParent, X, Y, W, H, Style = "", Handler = "", DllPath = "" )
Erase the cell.
SS_BlankCell( hCtrl, Col = "", Row = "" )
Creates COMBOBOX cell type.
SS_CreateCombo( hCtrl, Content, Height = 150 )
Converts date from / to integer.
SS_ConvertDate( hCtrl, Date, RefreshFormat = false )
Delete cell.
SS_DeleteCell( hCtrl, Col = "", Row = "" )
Delete column.
SS_DeleteCol( hCtrl, Col = "" )
Expand a cell to cover more than one cell.
SS_ExpandCell( hCtrl, Left, Top, Right, Bottom )
Get the cell parameters.
SS_GetCell( hCtrl, Col, Row, pQ, ByRef o1 = "", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "" )
Get all cell parameters into array.
SS_GetCellArray( hCtrl, V, Col = "", Row = "" )
Get the cell data.
SS_GetCellData( hCtrl, Col = "", Row = "" )
Get the current cells rect in active splitt.
SS_GetCellRect( hCtrl, ByRef top, ByRef left, ByRef right, ByRef bottom )
Get cell text
SS_GetCellText( hCtrl, Col = "", Row = "" )
Get cell data type
SS_GetCellType( hCtrl, Col = "", Row = "", Flag = 0 )
Get number of columns
SS_GetColCount( hCtrl )
Get column width.
SS_GetColWidth( hCtrl, col )
Get current cell in active window.
SS_GetCurrentCell( hCtrl, ByRef Col, ByRef Row )
Get current column in active window.
SS_GetCurrentCol( hCtrl )
Get current row in active window.
SS_GetCurrentRow( hCtrl )
Get active splitt window.
SS_GetCurrentWin( hCtrl )
Get date format.
SS_GetDateFormat( hCtrl )
Get lock cols in active splitt.
SS_GetLockCol( hCtrl )
Get lock rows in active splitt.
SS_GetLockRow( hCtrl )
Get multiselection.
SS_GetMultiSel( hCtrl, ByRef Top = "", ByRef Left = "", ByRef Right = "", ByRef Bottom = "" )
Get number of rows.
SS_GetRowCount( hCtrl )
Returns row height.
SS_GetRowHeight( hCtrl, Row )
Import a line of data.
SS_ImportLine( hCtrl, DataLine, SepChar = ";" )
Insert column.
SS_InsertCol( hCtrl, Col = -1 )
Insert row.
SS_InsertRow( hCtrl, Row = -1 )
Load a file.
SS_LoadFile( hCtrl, File )
Clears the sheet.
SS_NewSheet( hCtrl )
Recalculates the sheet.
SS_ReCalc( hCtrl )
Redraw the control.
SS_Redraw( hCtrl )
Save a file.
SS_SaveFile( hCtrl, File )
Scrolls current cell into view.
SS_ScrollCell( hCtrl )
Set content of the cell.
SS_SetCell( hCtrl, Col = "", Row = "", o1 = "", o2 = "", o3 = "", o4 = "", o5 = "", o6 = "", o7 = "", o8 = "", o9 = "", o10 = "", o11 = "" )
Set the data of the cell.
SS_SetCellData( hCtrl, Data, Col = "", Row = "" )
Set the cell binary data.
SS_SetCellBLOB( hCtrl, ByRef BLOB, Col = "", Row = "" )
Set the text of the selected cell.
SS_SetCellString( hCtrl, Txt = "", Type = "" )
Set column width.
SS_SetColWidth( hCtrl, Col, Width )
Set current cell in the active window.
SS_SetCurrentCell( hCtrl, Col, Row )
Set active splitt window.
SS_SetCurrentWin( hCtrl, Win )
Set date format.
SS_SetDateFormat( hCtrl, Format )
Set number of columns.
SS_SetColCount( hCtrl, nCols )
Set font.
SS_SetFont( HCtrl, Idx, Font )
Set all global parameters for the control.
SS_SetGlobal( hCtrl, g, cell, colhdr, rowhdr, winhdr )
Set individual global parameters for the control.
SS_SetGlobalFields( hCtrl, Fields, v1 = "", v2 = "", v3 = "", v4 = "", v5 = "", v6 = "", v7 = "" )
Lock columns in active split.
SS_SetLockCol( hCtrl, Cols = 1 )
Lock rows in active split.
SS_SetLockRow( hCtrl, Rows = 1 )
Set multiselection
SS_SetMultiSel( hCtrl, Left, Top, Right, Bottom )
Set number of rows.
SS_SetRowCount( hCtrl, nRows )
Set row height.
SS_SetRowHeight( hCtrl, Row = 0, Height = 0 )
Create horizontal splitt in current splitt at current row.
SS_SplittHor( hCtrl )
Create vertical splitt in current splitt at current col.
SS_SplittVer( hCtrl )
Close the current splitt.
SS_SplittClose( hCtrl )
Synchronizes a splitt window with it’s parent.
SS_SplittSync( hCtrl, Flag = 1 )