ImportClipboard

Description

Inserts data into a DataWindow control or DataStore object from tab-separated, comma-separated, or XML data on the clipboard.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object


Syntax

PowerBuilder

long dwcontrol.ImportClipboard ( {saveastype importtype}, { long startrow {, long endrow {, long startcolumn {, long endcolumn {, long dwstartcolumn } } } } } )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow.

importtype (optional for PowerBuilder)

An enumerated value of the SaveAsType DataWindow constant or a number representing that value (see SaveAsType). Valid import type arguments for ImportClipboard are:

Text!
CSV!
XML!

If you want to generate an XML trace file, the XML! argument is required.

startrow (optional for PowerBuilder)

The number of the first detail row in the clipboard that you want to copy. The default is 1.

For default XML import, if startrow is supplied, the first N (startrow -1) elements are skipped, where N is the DataWindow row size.

For template XML import, if startrow is supplied, the first  (startrow -1) occurrences of the repetitive row mapping defined in the template are skipped.

endrow (optional for PowerBuilder)

The number of the last detail row in the clipboard that you want to copy. The default is the rest of the rows.

For default XML import, if endrow is supplied, import stops when N * endrow elements have been imported, where N is the DataWindow row size.

For template XML import, if endrow is supplied, import stops after endrow occurrences of the repetitive row mapping defined in the template have been imported.

startcolumn (optional for PowerBuilder)

The number of the first column in the clipboard that you want to copy. The default is 1.

For default XML import, if startcolumn is supplied, import skips the first (startcolumn - 1) elements in each row.

This argument has no effect on template XML import.

endcolumn (optional for PowerBuilder)

The number of the last column in the clipboard that you want to copy. The default is the rest of the columns.

For default XML import, if endcolumn is supplied and is smaller than N, where N is the DataWindow row size, import skips the last (N - endcolumn) elements in each row.

This argument has no effect on template XML import.

dwstartcolumn (optional for PowerBuilder)

The number of the first column in the DataWindow control or DataStore that should receive data. The default is 1. This argument is supported for default and template XML import.


Return value

Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:

-1 -- No row is supplied or the startrow value supplied is greater than the number of rows in the string

-3 -- Invalid argument

-4 -- Invalid input

-11 -- XML Parsing Error; XML parser libraries not found or XML not well formed

-12 -- XML Template does not exist or does not match the DataWindow

-13 -- Unsupported DataWindow style for import

-14 -- Error resolving DataWindow nesting

Usage

The clipboard data must be formatted in tab-separated or comma-separated columns or in XML. The datatypes and order of the DataWindow object's columns must match the data on the clipboard.

If an XML or CSV column contains a leading double quote, it is assumed to be part of the column value. A leading double quote has to be closed to mark the end of an item.

All the arguments of this function are optional. You do not need to specify the importtype argument. The startcolumn and endcolumn arguments control the number of imported columns and the number of columns in the DataWindow that are affected. The dwstartcolumn argument specifies the first DataWindow column to be affected. The following formula calculates the last column to be affected.

dwstartcolumn + (endcolumn - startcolumn)

ImportClipboard does not support Crosstab DataWindow objects.

Examples

This statement copies all data in the clipboard to the DataWindow dw_employee starting at the first column:

dw_employee.ImportClipboard()

This statement copies all data in the clipboard to the DataWindow dw_employee starting at the first column and specifies that the data is in XML format:

dw_employee.ImportClipboard(XML!)

This statement imports rows 1 to 200 of the XML data on the clipboard, ignoring any template mappings before column 5:

dw_employee.ImportClipboard(XML!, 1, 200, 0, 0, 5)

This statement inserts data from the clipboard into the DataWindow dw_employee. It copies rows 2 through 30 and columns 3 through 8 on the clipboard to the DataWindow beginning in column 5. It adds 29 rows to the DataWindow with data in columns 5 through 10:

dw_employee.ImportClipboard(2,30,3,8,5)

See also

ImportFile

ImportString