This control is not a component and therefore cannot be picked from the gallery, it is quite easy to implement, though:
Simply create an OnClick-event for a menu item or a button, insert a few lines of code which creates a TDB2Web object and executes it, and that's it.The example below demonstrates the usage of all exported, i.e. accessable instance variables. To get a closer information about them, just click on the desired one.
procedure TDemoGridForm.Table2HTMLItemClick(Sender: TObject); var sFileName: String; begin with ( TDB2Web.Create( self, HKEY_CURRENT_USER, 'SOFTWARE\Your Company\Your Application' ) ) do try { required } DataGrid := self.MyGrid; // sets DataSource and DataSet // automatically { optional } ExportDir := '\temp\export\'; // sets the (local) export path ShowSetup := True; // brings up the setup dialogue ShowPage := True; // displays the created HTML-page PatternFile := 'MySweetHomepage.html'; // name of the pattern file OutputFile := 'Smiley'; // name of the output file HelpFileLoc := ''; // location of the helpfile if ( Exec() ) then // fires up the publisher sFileName := Outputfile; // gets the name of the output file finally Free(); end; end;
Notice that some Hint-messages are prepared to pass an OnHint-event. The demo application provides such an event that displays the hint in the StatusBar.
= required,
= optional,
= write only
Note: There can only be one data source, so the datasource-properties (marked green) are to be used alternatively.
- Sets the datasource to a TDBGrid.
- Sets the datasource to a TDataSource.
- Sets the datasource to a TDataSet (TQuery or TTable).
- Sets / gets the (local) directory where the created files are stored.
- Sets the location of the publisher's helpfile.
- Sets / gets the name of the created file.
- Sets / gets the name of the pattern file.
- Determines whether to show the created HTML-page after export.
- Determines whether to bring up the setup dialogue.
= required,
= optional,
= write only
Purpose
- Sets the publisher's datasource to a TDBGrid.
Type
- TDBGrid
Default
- none
Note
- The grid's DataSource-property must be accessable; and the datasource's DataSet- property must also be accessable.
Example:
- oDB2Web.DataGrid := self.MyGrid;
Purpose
- Sets the publisher's datasource to a TDataSource.
Type
- TDataSource
Default
- none
Note
- The datasource's DataSet-property must be accessable.
Example:
- oDB2Web.DataSource := self.MySource;
Purpose
- Sets the publisher's datasource to a TDataSet (TQuery or TTable).
Type
- TDataSet
Default
- none
Note
- -
Example:
- oDB2Web.DataSet := self.MyQuery;
Purpose
- Sets / gets the (local) directory where the created files are stored.
Type
- String
Default
- none
Notes
- If nothing else is specified the HTML-file and all attached memo files and graphic files will be exported to the current directory.
- If the directory does not exist it will be created. You will be informed if the creation fails, and export will not process.
- Closing backslash is required.
Example:
- oDB2Web.ExportDir := '\temp\';
sets the directory to the TEMP-path of the current drive.
Purpose
- Sets the the path, where the user's helpfile DB2WEB.HLP is located.
Type
- String
Default
- .\Help\
Notes
- Closing backslash is required.
- To set the location to the application's path, assign an empty string.
- Name of the helpfile is DB2WEB.HLP.
Example:
- oDB2Web.HelpFileLoc := '.\WinHelp\';
sets the location of the helpfile to the WINHELP-subdirectory of the current directory.
Purpose
- Sets / gets the name of the output file.
Type
- String
Default
- Basic name of the given dataset plus the extension .HTM
Notes
- The default will be retrieved either from the DOS-name of the table (if it is a TTable) or from the name given in the SQL-SELECT- statement.
- If the name has more than eight characters, it will simply be cut off.
- On writing to the property directory qualifiers will be cut off. To set the output directory use the ExportDir-property.
- The extension will be replaced by .HTM.
- The property's read-result is a fully qualified file name including the current ExportDir-value.
Examples:
- oDB2Web.OutputFile := 'Smiley';
oDB2Web.ExportDir := '\temp\';
sFileName := oDB2Web.OutputFile; // result is '\temp\Smiley.htm'
oDB2Web.DataSet := self.MyQuery; // SQL is: SELECT * FROM RhabarberRhabarber R JOIN..
oDB2Web.ExportDir := '.\output\';
sFileName := oDB2Web.OutputFile; // result is '.\output\Rhabarbe.htm'See also:
- General file naming and Output restrictions
Purpose
- Sets / gets the name of the pattern file (if any)
Type
- String
Default
- Pattern.htm
Notes
- TDB2Web expects an HTML-based pattern file for its work. If no pattern file is specified, the default one will be used. If this does not exist, it will be created.
Example:
- oDB2Web.PatternFile := 'MySweetHomepage.htm'
See also:
- How to prepare a pattern file
Purpose
- Determines whether to show the created HTML-page after export.
If the page is not to be shown, the user will be informed by a simple info window that the page has been created (if so!). This window disappears after a period of ten seconds.Type
- Boolean
Default
- True
Note
- If the value is True the currently selected browser will be fired up (Shareware version: in-build only).
Example:
- oDB2Web.ShowPage := False;
Purpose
- Determines whether to bring up the setup dialogue.
Type
- Boolean
Default
- True
Note
- If the setup is not shown, export happens with the settings read from Windows registry.
Example:
- oDB2Web.ShowSetup := False;
constructor TDB2Web.Create(AOwner: TComponent; rKey: HKey; rPath: String);
Arguments
AOwner TComponent Owner of the object rKey HKey Sets the registry key where to store and restore settings for TDB2Web (should be HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER) rPath String Sets the registry path within rKey where to store and restore settings for TDB2Web. See example for usage.
function TDB2Web.Exec: Boolean
- Purpose
- Main execution loop
- Returns
- boolean - False if an error occurred, True if not
See example for usage.
All options except the table caption and the name of the output file will be stored in and read from the Windows registry.
If not yet done, all registry entries will be created when clicking on Ok of the setup dialogue.
So, the first time an application calls a TDB2Web-object you might get an error message saying that some value could not be read from registry. You can ignore this message since default values are set.
You will find some values and four subdirs beneath the specified registry path:
- ColumnAttributes
- GraphicOptions
- TableAttributes
- TableCaption