Maptitude GISDK Help |
Exports the contents of a view to a new table.
Row Order option added in Version 2013. Return value and MEM class added in Version 2015. ExcelX and MSSQLD classes added in Version 2016. Additional Fields array updated in Version 2018.
new_view_name = ExportView(string view_set_name, string class, string file_name, array field_names, array options)
Argument |
Contents |
view_set_name |
The name of the view and selection set, separated by a vertical bar |
class |
Class of new table to create ("dBASE"," FFA"," FFB", "CSV", "EXCEL", "EXCELX", "MSSQLD", or " MEM") |
file_name |
File name for the new table, the spec for a "MSSQLD" table, or the proposed view name for a "MEM" table |
field_names |
The list of fields to store in the new table, or null to store all fields in the new table |
Option |
Type |
Contents |
Additional Fields |
Array |
An array that contains one array element for each additional field to append to the new file. Each array element has the format {name, type, width, decimals, internal_index_flag, description, format}. For more information, see CreateTable(). |
CSV Drop Quotes |
Boolean |
If "True" when exporting to a comma-separated file, do not have quotes around string field values in the exported file (default is "False"). |
CSV Header |
Boolean |
If "True" when exporting to a comma-separated file, the first line of the file contains field names, and data starts at the second line (default is "False"). |
Dictionary Description |
String |
A description to be stored in the first line of the resulting FFA, FFB, or CSV dictionary file. |
Force Numeric Type |
String |
Type should be chosen from "double", "float", "integer", "long", "real", or "short". All numeric fields will be exported using the specified type whenever allowed by the underlying database that is being exported to. |
Indexed Fields |
Array |
A list of fields to be internally indexed in the new table. |
Unique Fields |
2 arrays |
An array of field names, and an array indicating a sort order. If several records in the view have identical values for all the indicated fields, only one will be exported. The sort order (if it is not null) indicates which record to export. The format of the sort order is identical to that used in GetNextRecord(). |
Secondary |
Array |
For MSSQLD, an options array with values for "Table" (the table name) and "Schema" (the schema name); see the second example. |
Row Order |
Array |
An array that indicates the desired sort order, or null for natural order. The array is an array of field name-order pairs: |
Element |
Type |
Contents |
1 |
String |
The name of the field |
2 |
String |
"Ascending" or "Descending" |
A string containing the name of the view, when a MEM table is created, otherwise null.
The file types include FFA for fixed-format text (ASCII), FFB for fixed-format binary, and CSV for comma-separated text (values).
When exporting to a CSV, FFB, or FFA file, ExportView() automatically creates a dictionary file in the proper format.
ExcelX provides a way to export to .xlsx file format.
For MSSQLD, file_name is a spec for the Microsoft SQL Server database in the form server_name|database_name, where server_name is the name of the SQL Server instance and database_name is the name of the database; see the second example.
The tables created with the MEM class are stored in memory instead of being stored on disc, and persist in memory until closed with CloseView() or until the program is closed.
The old format for the CSV Header option, with no value, is still supported.
If a file of the given name already exists, it is deleted before the view is exported. No warning is issued; if the user previously selected the file name with ChooseFilename(), that function already warned the user about the conflict.
Use OpenTable() to open the new table.
ExportView() displays a progress bar. To add a Cancel button to the progress bar, precede the function call with an "on escape" clause. For more information, see Error Handling.
ExportView("Customers|Top Ten", "CSV", "topten.csv",
{"Name", "Address", "Sales", "SalesRep"},
{
{"CSV Header", "True"},
{"Indexed Fields", {"Name", "Sales"}}
})
// Replace with server name, instance name and database name
database_name = "server\instance|database"
opts = null
opts.Secondary.Table = "Table" // Replace with table name
opts.Secondary.Schema = "dbo" // replace with schema name
ExportView("Customers|Top Ten", "MSSQLD", database_name,,opts)
Error Type |
Meaning |
Error |
Unable to create the table (e.g., the file is currently in use, or disk space is insufficient) |
Escape |
The user clicked Cancel |
NotFound |
The view or set name is invalid |
Function |
Summary |
Creates an empty table and opens it as a view |
|
Exports the contents of an editor to a new table |
|
Checks whether files are in use by Maptitude |
©2025 Caliper Corporation | www.caliper.com |