VCL
TAdvSpreadGrid
Powerful spreadsheet function calculation support added to the full TAdvStringGrid feature set
Tips and Frequently Asked Questions
How to add formula support in TAdvSpreadGrid to access DB tables
With this small DB sample mathlib, the concept is demonstrated to add formula support in TAdvSpreadGrid to access DB tables:
type TDBMathLib = class(TMathLib) private { Private declarations } FDataSource: TDataSource; protected { Protected declarations } procedure Notification(AComponent: TComponent; AOperation: TOperation); override; public { Public declarations } function HandlesStrFunction(FuncName:string):Boolean; override; function CalcStrFunction(FuncName:string;Params:TStringList;var ErrType,ErrParam: Integer):string; override; published { Published declarations } property DataSource: TDataSource read FDataSource write FDataSource; end; implementation { TDBMathLib } function TDBMathLib.CalcStrFunction(FuncName: string; Params: TStringList; var ErrType, ErrParam: Integer): string; var s: string; n,e: integer; fld: TField; begin if (FuncName = ''DBV'') then begin if Params.Count <> 2 then begin ErrType := Error_InvalidNrOfParams; Exit; end; if not Assigned(DataSource) then begin ErrType := Error_NoDataSource; Exit; end; if not Assigned(DataSource.DataSet) then begin ErrType := Error_NoDataSet; Exit; end; if not DataSource.DataSet.Active then begin ErrType := Error_NoDataSetActive; Exit; end; s := Params.Strings[0]; // DB FIELD value fld := DataSource.DataSet.FieldByName(s); if not Assigned(fld) then begin ErrType := Error_InvalidValue; ErrParam := 1; end else begin val(Params.Strings[1],n, e); DataSource.DataSet.First; DataSource.DataSet.MoveBy(n); Result := fld.AsString; end; end; end; function TDBMathLib.HandlesStrFunction(FuncName: string): Boolean; begin Result := FuncName = ''DBV''; end; procedure TDBMathLib.Notification(AComponent: TComponent; AOperation: TOperation); begin inherited; if (AOperation = opRemove) and (AComponent = FDataSource) then FDataSource := nil; end;
Compatibility
- Delphi 7, 2007, 2010, 2009, XE, XE2, XE3, XE4, XE5, XE6, XE7, XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo, 10.3 Rio, 10.4 Sydney, 11 Alexandria, C++Builder 2007, 2009, 2010, XE, XE2, XE3, XE4, XE5, XE6, XE7, XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo, 10.3 Rio, 10.4 Sydney, 11 Alexandria (Professional/Enterprise/Architect)
Licensing
- Licensing FAQ
- License for commercial use: Single developer license, Small team license, Site license
- Includes full source code
- Ask questions to our engineers related to purchased product via Support Center
- Free 1 year updates and new releases
- After 1 year, a discount renewal is offered for a 1 year extension. *
* offer valid for 30 days after end of license. Discount price is subject to change.