OBS/Auswertung/DataInOut/SpreadGrid
Zur Navigation springen
Zur Suche springen
Verwendung von eigenen Macros innerhalb des Grids
Um ein eigenes Macro innerhalb des Grids zu verwenden muss das Macro im dafür vorgesehenen Bereich angelegt werden (rechts neben dem Grid).
Beispiel für ein Macro mit Parametern:
function Test(nVal: integer; cText: string): string; begin result := cText+ ' ' + IntToStr(nVal); end;
der Aufruf erfolgt innerhalb einer Zelle:
=macro("test", "15", "Ausgabe")
Folgende Methoden stehen innerhalb der Makros für den Zugriff auf das Grid bereit
Schreibt den Text "cText" in die angegebene Zelle
- procedure SetCellText(oGrid: TObject; x, y: integer; cText: string);
- procedure SetGridText(oGrid: TObject; cCell: string; cText: string);
Beispiele:
SetCellText(oGrid, 2, 2, 'Test'); SetGridText(oGrid, 'C3', 'Test');
Schreibt eine Zahl nValue in die angegebene Zelle
- procedure SetCellValue(oGrid: TObject; x, y: integer; nValue: Double);
- procedure SetGridValue(oGrid: TObject; cCell: string; nValue: Double);
Liest den Text aus der angegebenen Zelle
- function GetCellText(oGrid: TObject; x, y: integer): string;
- function GetGridText(oGrid: TObject; cCell: string): string;
Liest einen Wert aus der angebenen Zelle
function GetCellValue(oGrid: TObject; x, y: integer): Double;
- function GetGridValue(oGrid: TObject; cCell: string): Double;
Setzt die Zeilenanhal des Grids
- procedure SetGridRowCount(oGrid: TObject; nRows: integer);
Setzt die Spaltenanzahl des Grids
- procedure SetGridColCount(oGrid: TObject; nCols: integer);
Setzt die Hintergrundfarbe der Zeile nRow auf die Farbe oColor
- procedure SetGridRowColor(oGrid: TObject; nRow: integer; oColor: TColor);
Beispiel:
SetGridRowColor(oGrid, 2, clYellow); SetGridRowColor(oGrid, 3, clRed);
Aufruf beim Klicken in das Grid
- procedure OnClickCell(ARow, ACol: Integer);
Beispiel:
procedure OnClickCell(ARow, ACol: Integer); begin DebugLine(CRLF+'ClickCell'); DebugLine('Zeile '+IntToStr(ARow)); //Gibt die angeklickte Zeile aus DebugLine('Spalte '+IntToStr(ACol)); //Gibt die angeklickte Spalte aus end;
- procedure OnCellChanging(OldRow, OldCol, NewRow, NewCol: Integer);
procedure OnCellChanging(OldRow, OldCol, NewRow, NewCol: Integer); begin
DebugLine(CRLF+'OnCellChanging'); DebugLine('Alt Reihe '+IntToStr(OldRow)); DebugLine('Alt Spalte '+IntToStr(OldCol)); DebugLine('Neu Reihe '+IntToStr(NewRow)); DebugLine('Neu Spalte '+IntToStr(NewCol));
end;
procedure OnDblClickCell(ARow, ACol: Integer); begin
DebugLine(CRLF+'DblClickCel'); DebugLine('Reihe '+IntToStr(ARow)); DebugLine('Spalte '+IntToStr(ACol));
end;
procedure FillGrid(); begin
SetGridRowCount(oGrid,100); ClearGridRows(oGrid,5,0);
end;
Folgende Funktionen können innerhalb des Grids verwendet werden:
Constants
- PI
- E
- True
- False
Single parameter functions
- ABS(parameter) : absolute value
- ROUND(parameter) : rounds value
- TRUNC(parameter) : truncates value
- CEILING(parameter; significance) : rounds the parameter to the nearest multiple of significance
- FRAC(parameter) : returns fractional part of value
- FACT(parameter) : factioral of value
- INT(parameter) : int part of value
- SIN(parameter) : sine of value
- COS(parameter) : cosine of value
- TAN(parameter) : tangens of value
- COTAN(parameter) : cotangens of value
- SINH(parameter) : hyperbolic sine of value
- COSH(parameter) : hyperbolic cosine of value
- TANH(parameter) : hyperbolic tangens of value
- COTANH(parameter) : hyperbolic cotangens of value
- ASIN(parameter) : arcsin of value
- ACOS(parameter) : arccos of value
- ATAN(parameter) : arctangens of value
- ACOTAN(parameter) : arccotangens of value
- LN(parameter) : natural logarithm of value
- LOG2(parameter) : base 2 logarithm of value
- LOG10(parameter) : base 10 logarithm of value
- EXP(parameter) : exponential of value
- RAND(parameter) : random between 0 and value
- RADIANS(parameter) : converts degrees to radians
- DEGREES(parameter) : converts radians to degrees
- SQR(parameter) : square of value
- SQRT(parameter) : square root of value
- CUBE(parameter) : cubic square of value
- CHS(parameter) : change sign
- POWER(parameter,exp) : parameter to exponent exp
Multi parameter functions
- LT(param1;param2) : larger than : returns 1 of param1>param2
- ST(param1;param2) : smaller than : returns 1 of param1<param2
- EQ(param1;param2) : equal : returns 1 of param1=param2 else 0
- CHOOSE(sel;param1;param2) : returns param1 if sel>0 else param2
Cell range functions
- SUM(range) : sum of all cell values in range
- PRODUCT(rangfe) : product of all cell values in range
- AVERAGE(range) : average of all cell values in range
- MIN(range) : min. cell value in range
- MAX(range) : max. cell value in range
- COUNT(range) : nr. of cells in range
- COUNTA(range) : nr of non blank cells in range
- COUNTIF(range;condition) : nr of cells meeting condition in range
- STDEV(range) : standard deviation of range
- STDEVP(range) : standard deviation of total population of range
- DEVSQ(range) : sum of squares of deviations of range
- VAR(range) : variance of range
Date & Time functions
- HOUR(parameter) : gets the hour from a cell containing a valid time string
- MIN(parameter) : gets the minute from a cell containing a valid time string
- SECOND(parameter) : gets the second from a cell containing a valid time string
- DAY(parameter) : gets the day from a cell containing a valid time string
- MONTH(parameter) : gets the month from a cell containing a valid time string
- YEAR(parameter) : gets the year from a cell containing a valid time string
- WEEKDAY(parameter) : gets the day of the week from a cell containing a valid time string
- TODAY : gets the current day
- NOW : gets the current time
Logical functions
- AND(parameters) : logical AND function
- OR((parameters) : logical OR function
- NAND(parameters) : logical NAND function
- NOR((parameters) : logical NOR function
- XOR((parameters) : logical XOR function
- NOT(parameter) : logical NOT function
- TRUE : constant returning true
- FALSE: constant returning false
String functions
- LEN(parameter) : returns the length of a string value
- LOWER(parameter) : returns string in lowercase
- UPPER(parameter) : returns string in uppercase
- CONCATENATE(parameter list) : returns concatenated string of parameters
- SUBSTITUTE(param text; param oldtext; param new text) : returns string with oldtext replaced by newtext
- LEFT(param string;len integer) : returns first len charactares of string
- RIGHT(param string;len integer) : returns last len characters of string
- MID(param string; pos; len: integer): returns len characters starting from position pos in string
- TRIM(param) : removes all spaces from text except spaces between words
- SEARCH(find text; text) : returns position of string find text in text
- LOOKUP(param; range1, range2) : returns the value of the element in range2 that has the index of the matching element in range1 for param
- MATCH(lookup; range) : returns the index of the element param in the range
- INDEX(range; val1, val2) : returns the value of element at index val1,val2 in the range