描述
Inserts data into a DataWindow control, DataStore object, or graph control from data in a file.一个文件插入数据到一个数据窗口控件,数据存储对象,图形或数据控制。 The data can be tab-separated text, comma-separated text, XML, or dBase format 2 or 3.这些数据可以制表符分隔的文本,以逗号分隔的文本,XML或dBASE格式2或3。 The format of the file depends on whether the target is a DataWindow (or DataStore) or a graph and on the type of graph.该文件的格式取决于该目标是一个数据窗口(或数据存储)或图和图型。
For DataWindow and DataStore syntax, see the ImportFile method for DataWindows in the DataWindow Reference or the online Help .对于数据窗口和DataStore的语法,请参阅联机帮助 ImportFile 的方法,在数据窗口DataWindows参考或 。
Applies to适用于
Graph controls in windows and user objects.图控制在窗口和用户对象。 Does not apply to graphs within DataWindow objects, because their data comes directly from the DataWindow.不适用于在数据窗口对象的图形,因为它们的数据直接来自数据窗口。
Syntax句法
graphname . ImportFile ( { importtype}, filename {, startrow {, endrow {, startcolumn } } } ) graphname。ImportFile((importtype),(文件名,startrow(,endrow(,startcolumn))))
Argument论据
|
Description描述
|
graphname graphname
|
The name of the graph control to which you want to copy data from the specified file.该控件的名称图,您要复制文件数据从指定的。
|
importtype (optional) importtype(可选)
|
An enumerated value of the SaveAsType DataWindow constant.一个数据窗口不断枚举值的SaveAsType。 If this argument is specified, the importtype argument can be specified without an extension.如果该参数指定,importtype参数可以指定不带扩展名。 Valid type arguments for ImportFile are:论点ImportFile有效的类型有:
-
Text!文字!
-
CSV! CSV格式!
-
XML! XML的!
-
DBase2! DBase2!
-
DBase3! DBase3!
|
filename 文件名
|
A string whose value is the name of the file from which you want to copy data.一个字符串,其值是文件名从你要复制的数据。 The file must be an ASCII, tab-separated file (TXT), comma-separated file (CSV), Extensible ), or dBase format 2 or 3 file (DBF).该文件必须是一个ASCII,制表符分隔的文件(TXT),逗号分隔文件(CSV),可扩展),或2或3的dBase格式文件(DBF的)。 Specify the file's full name.指定文件的全名。 If the optional importtype is not specified, the name must end in the appropriate extension.如果没有指定可选的importtype,名称必须结束在适当延长。
If you do not specify filename or if it is null , ImportFile prompts the user for a file name.如果你不指定文件名 ,或者如果它为null,ImportFile提示文件的名称为一个用户。 The remaining arguments are ignored.剩余的参数将被忽略。
|
startrow (optional) startrow(可选)
|
The number of the first detail row in the file that you want to copy.该文件要拷贝数的第一行中的细节。 The default is 1.默认是1。
For default XML import, if startrow is supplied, the first N ( startrow -1) elements are skipped, where N is the DataWindow row size.对于默认XML导入,如果startrow提供, 第一个N(startrow -1)的元素都被跳过, 其中 N是数据窗口行的大小。
For template XML import, if startrow is supplied, the first对于XML导入模板,如果startrow提供,首 ( startrow -1) occurrences of the repetitive row mapping defined in the template are skipped. (startrow -1)发生了重复的行映射模板中定义跳过。
|
endrow (optional) endrow(可选)
|
The number of the last detail row in the file 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.对于默认XML导入,如果endrow提供,进口停止当 N * endrow内容已经进口的, 其中 N是数据窗口行的大小。
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.对于XML导入模板,如果endrow提供,该模板中定义导入后停止endrow行中出现的重复测绘已导入。
|
startcolumn (optional) startcolumn(可选)
|
The number of the first column in the file that you want to copy.匮乏的拷贝数列的第一个文件中的你。 The default is 1.默认是1。
For default XML import, if startcolumn is supplied, import skips the first ( startcolumn - 1) elements in each row.对于默认XML导入,如果startcolumn提供,进口跳过第一(startcolumn - 1)在每个行元素。
This argument has no effect on template XML import.这一论点并没有对模板的效果XML导入。
|
Returns返回
Long.长。 Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:返回发生错误的行的数目进口,如果成功,它下面的一个负整数,如果一:
-
-1 No rows or startrow value supplied is greater than the number of rows in the file -1没有行或startrow值是文件大于供给的数量的行
-
-2 Empty file or input data does not match number of columns or required column type -2文件为空或输入的数据类型不匹配的列数或要求列
-
-3 Invalid argument -3无效参数
-
-4 Invalid input -4输入无效
-
-5 Could not open the file -5无法打开文件
-
-6 Could not close the file -6无法关闭文件
-
-7 Error reading the text -7错误阅读文本
-
-8 Unsupported file name suffix (must be *.txt, *.csv, *.dbf or *.xml) -8不支持的文件名后缀(必须是*. txt文件,*. CSV格式,*. dbf或*. xml的)
-
-10 Unsupported dBase file format (not version 2 or 3) -10不受支持的dBASE文件格式(而不是版本2或3)
-
-11 XML Parsing Error; XML parser libraries not found or XML not well formed -11 XML解析错误; XML解析器库不存在或没有很好形成的XML
-
-12 XML Template does not exist or does not match the DataWindow -12 XML模板不存在或不匹配的数据窗口
If any argument's value is null , ImportFile returns null . If the optional importtype argument is specified and is not a valid type, ImportFile returns -3.如果任何参数的值是 null, 返回 null ImportFile。如果可选importtype参数指定,而不是一个有效的类型,ImportFile返回-3。
Usage用法
The format of the file can be indicated by specifying the optional importtype parameter, or by including the appropriate file extension.该文件的格式,可通过指定可选的显示importtype参数,或通过包括适当的文件扩展名。
For graph controls, ImportFile only uses three columns and ignores other columns.对于图形控制,ImportFile只使用3列,而忽略其他列。 Each row of data must contain three pieces of information.每个数据行中必须包含三个信息件。 The information depends on the type of graph:该信息取决于图表类型:
-
For all graph types except scatter, the first column to be imported is the series name, the second column contains the category, and the third column contains the data.对于所有类型,除了散布图,第一列从外地输入的是该系列的名称,第二列包含类,第三列包含的数据。
-
For scatter graphs, the first column to be imported is the series name, the second column is the data's x value, and the third column is the y value.对于散布图,第一列从外地输入的是该系列的名称,第二列是数据的x值,第三列是y值。
You can add data to more than one series by specifying different series names in the first column.您可以添加数据到多个系列的第一列指定不同的系列名称研究。 To let users select the file to import, specify a null string for filename . PowerBuilder displays the Select Import File dialog box.为了让用户选择要导入的文件, 文件名指定一个空字符串。PowerBuilder中显示选择导入文件对话框。
Double quotes The location and number of double quote marks in a field in a tab delimited file affect how they are handled when the file is imported. 双引号双数场引号中的位置和一个制表符分隔的文件影响到他们如何处理时,该文件是进口的。 If a string is enclosed in one pair of double quotes, the quotes are discarded.如果字符串被双引号括在一对的报价将被丢弃。 If it is enclosed in three pairs of double quotes, one pair is retained when the string is imported.如果是双引号括在三对,一对是保留字符串时是进口的。 If the string is enclosed in two pairs of double quotes, the first pair is considered to enclose a null string, and the rest of the string is discarded.如果字符串引号括在双两对,第一对被认为是一个空字符串括起来,而其余的字符串将被丢弃。
When there is a double quote at the beginning of a string, any characters after the second double quote are discarded.当有一个双引号的字符串开始时,双引号的所有字符后,第二次将被丢弃。 If there is no second double quote, the tab character delimiting the fields is not recognized as a field separator and all characters up to the next occurrence of a double quote, including a carriage return, are considered to be part of the string.如果没有第二个引号,制表符分隔的返回字段是不承认所有作为字段分隔符和字组成的一个运输的下一个出现的一个双引号,包括被认为是字符串的一部分。 A validation error is generated if the combined strings exceed the length of the first string.验证错误,如果合并生成字符串的字符串长度超过了第一。
Double quotes after the first character in the string are rendered literally.双引号字符的字符串字面呈现后的第一次。 Here are some examples of how tab-delimited strings are imported into a two-column DataWindow:这里有一些例子,说明制表符分隔的字符串被导入到一个两列的数据窗口:
Text in file文本文件
|
Result结果
|
"Joe" TAB "Donaldson" “乔”统计表“唐纳森”
|
Joe Donaldson乔唐纳森
|
Bernice TAB """Ramakrishnan"""伯尼斯统计表“”“莱玛克里斯南”“”
|
Bernice "Ramakrishnan"伯尼斯“莱玛克里斯南”
|
""Mary"" TAB ""Li"" “”玛丽“”标签“,”礼“”
|
Empty cells空细胞
|
"Mich"ael TAB """Lopes""" “迈克”机场快线统计表“”“洛佩斯”“”
|
Mich "Lopes"迈克“洛佩斯”
|
"Amy TAB Doherty" “艾米统计表多尔蒂”
|
Amy<TAB>Doherty in first cell, second cell empty艾米<Tab>键多尔蒂在第一个单元格,第二个单元格为空
|
3""" TAB 4" 3“”“标签4”
|
3""" 4" 3“”“4”
|
Specifying a null string for file name If you specify a null string for filename , the remaining arguments are ignored. 指定一个文件名称为空字符串 ,如果你指定一个空字符串为文件名 ,其余的参数被忽略。 All the rows and columns in the file are imported.文件的所有行和列的都是进口的。
Examples范例
Example 1 示例1
This statement copies all the data in the file D:\EMPLOYEE.TXT to gr_employee starting at the first row:本声明中的所有数据复制的文件D:\ EMPLOYEE.TXT以gr_employee行开始在第一:
gr_employee. ImportFile ("D:\EMPLOYEE.TXT") gr_employee。ImportFile(的“D:\ EMPLOYEE.TXT”)
Example 2 例2
This statement copies the data from the file D:\EMPLOYEE.TXT starting with row 2 column 3 and ending with row 30 column 5 to the graph gr_employee :本声明的副本文件 D中的数据来自:\ EMPLOYEE.TXT开始,第2行第3列和行结尾的5至30列图gr_employee:
gr_employee. ImportFile ("D:\EMPLOYEE.TXT", 2, 30, 3) gr_employee。ImportFile(的“D:\ EMPLOYEE.TXT”,2,30,3)
Example 3 例3
The following statements are equivalent.下面的语句是等价的。 Both import the contents of the XML file named myxmldata :这两种导入XML文件的内容命名myxmldata:
gr_control.ImportFile(myxmldata.xml) gr_control.ImportFile(myxmldata.xml)
gr_control.ImportFile(XML!, myxmldata) gr_control.ImportFile(XML的!,myxmldata)
Example 4 范例4
This example causes PowerBuilder to display the Specify Import File dialog box:这个例子使PowerBuilder中显示指定文件导入对话框:
string null_str字符串null_str
SetNull(null_str) SetNull(null_str)
dw_main. ImportFile (null_str) dw_main。ImportFile(null_str)