![]() |
Previous Top Next |
Import and Export
|
1. | Use a "DatabaseConnection" object and set the properties:
|
The method "Application.GetDatabaseSettings" returns a new object for a database connection:
|
2. | Call "Application.GetDatabaseImportElementList" to get a collection of the resulting columns of the SQL query:
|
|
Dim objElementList As ElementList
|
Set objElementList = objSpy.GetDatabaseImportElementList(objImpSettings)
|
|
This collection gives you the opportunity to control which columns should be imported and what type the new elements will become. Each item of the collection represents one column to import. If you remove an item, the corresponding column will not be imported. You can additionally modify the "ElementListItem.ElementKind" property, to set the type of the created XML elements for each column.
|
|
Please consider that GetDatabaseImportElementList() executes the SQL query and could initiate a time consuming call. To avoid this, it is possible to pass a null-pointer (Nothing in VisualBasic) as the second parameter to ImportFromDatabase() to import all columns as plain XML elements.
|
3. | Start the import with "Application.ImportFromDatabase":
|
Dim objImpDoc As Document
|
Set objImpDoc = objSpy.ImportFromDatabase(objImpSettings,objElementList)
|
1. | Use a "TextImportExportSettings" object and set the properties:
|
The method "Application.GetTextImportExportSettings" returns a new object to specify a text file for import.
|
Dim objImpSettings As TextImportExportSettings
|
Set objImpSettings = objSpy.GetTextImportExportSettings
|
|
You have to set at least the ImportFile property to the path of the file for the import. Another important property is HeaderRow. Set it to False, if the text file does not contain a leading line as a header row.
|
|
objImpSettings.ImportFile = "C:\myFile.txt"
|
objImpSettings.HeaderRow = False
|
|
|
2. Call "Application.GetTextImportElementList" to get a collection of all columns inside the text file:
|
|
Dim objElementList As ElementList
|
Set objElementList = objSpy.GetTextImportElementList(objImpSettings)
|
3. | Start the import with "Application.ImportFromText":
|
Dim objImpDoc As Document
|
Set objImpDoc = objSpy.ImportFromText(objImpSettings,objElementList)
|
1. | Use a "DatabaseConnection" object and set the necessary properties.
|
All properties except "SQLSelect" are important for the export. "ADOConnection" or "File" defines the target for the output. You need to set only one of them.
|
2. | Fill an "ExportSettings" object with the required values.
|
These properties are the same options as those available in the export dialog of XMLSpy. Select the menu option Convert | Export to Text files/Database to see the options and try a combination of export settings. After that it is easy to transfer these settings to the properties of the interface.
|
|
Call "Application.GetExportSettings" to get a ExportSettings object:
|
|
Dim objExpSettings As ExportSettings
|
Set objExpSettings = objSpy.GetExportSettings
|
|
objExpSettings.CreateKeys = False
|
objExpSettings.ExportAllElements = False
|
objExpSettings.SubLevelLimit = 2
|
3. | Build an element list with "Document.GetExportElementList".
|
The element list enables you to eliminate XML elements from the export process. It also gives you information about the record and field count in the "RecordCount" and "FieldCount" properties. Set the "ExportSettings.ElementList" property to this collection. It is possible to set the element list to null/Nothing (default) to export all elements.
|
|
4. | Call "Document.ExportToDatabase" to execute the export.
|
The description of the ExportToDatabase method contains also a code example for a database export.
|
|
1. | Use a "TextImportExportSettings" object and set the necessary properties.
|
|
2. | Fill an "ExportSettings" object with the required values.
|
See item number 2 from "Export to database" earlier on this page.
|
|
3. Build an element list with "Document.GetExportElementList".
|
See item number 3 from "Export to database" earlier on this page.
|
|
4. Call "Document.ExportToText" to execute the export.
|
The description of the ExportToText method contains also a code example for a database export.
|
|
|