描述
Inserts data into a DataWindow control, DataStore object, or graph control from data in a file.一個(gè)文件插入數(shù)據(jù)到一個(gè)數(shù)據(jù)窗口控件,數(shù)據(jù)存儲(chǔ)對(duì)象,圖形或數(shù)據(jù)控制。 The data can be tab-separated text, comma-separated text, XML, or dBase format 2 or 3.這些數(shù)據(jù)可以制表符分隔的文本,以逗號(hào)分隔的文本,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.該文件的格式取決于該目標(biāo)是一個(gè)數(shù)據(jù)窗口(或數(shù)據(jù)存儲(chǔ))或圖和圖型。
For DataWindow and DataStore syntax, see the ImportFile method for DataWindows in the DataWindow Reference or the online Help .對(duì)于數(shù)據(jù)窗口和DataStore的語(yǔ)法,請(qǐng)參閱聯(lián)機(jī)幫助 ImportFile 的方法,在數(shù)據(jù)窗口DataWindows參考或 。
Applies to適用于
Graph controls in windows and user objects.圖控制在窗口和用戶對(duì)象。 Does not apply to graphs within DataWindow objects, because their data comes directly from the DataWindow.不適用于在數(shù)據(jù)窗口對(duì)象的圖形,因?yàn)樗鼈兊臄?shù)據(jù)直接來(lái)自數(shù)據(jù)窗口。
Syntax句法
graphname . ImportFile ( { importtype}, filename {, startrow {, endrow {, startcolumn } } } ) graphname。ImportFile((importtype),(文件名,startrow(,endrow(,startcolumn))))
Argument論據(jù)
|
Description描述
|
graphname graphname
|
The name of the graph control to which you want to copy data from the specified file.該控件的名稱圖,您要復(fù)制文件數(shù)據(jù)從指定的。
|
importtype (optional) importtype(可選)
|
An enumerated value of the SaveAsType DataWindow constant.一個(gè)數(shù)據(jù)窗口不斷枚舉值的SaveAsType。 If this argument is specified, the importtype argument can be specified without an extension.如果該參數(shù)指定,importtype參數(shù)可以指定不帶擴(kuò)展名。 Valid type arguments for ImportFile are:論點(diǎn)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.一個(gè)字符串,其值是文件名從你要復(fù)制的數(shù)據(jù)。 The file must be an ASCII, tab-separated file (TXT), comma-separated file (CSV), Extensible ), or dBase format 2 or 3 file (DBF).該文件必須是一個(gè)ASCII,制表符分隔的文件(TXT),逗號(hào)分隔文件(CSV),可擴(kuò)展),或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.如果沒(méi)有指定可選的importtype,名稱必須結(jié)束在適當(dāng)延長(zhǎng)。
If you do not specify filename or if it is null , ImportFile prompts the user for a file name.如果你不指定文件名 ,或者如果它為null,ImportFile提示文件的名稱為一個(gè)用戶。 The remaining arguments are ignored.剩余的參數(shù)將被忽略。
|
startrow (optional) startrow(可選)
|
The number of the first detail row in the file that you want to copy.該文件要拷貝數(shù)的第一行中的細(xì)節(jié)。 The default is 1.默認(rèn)是1。
For default XML import, if startrow is supplied, the first N ( startrow -1) elements are skipped, where N is the DataWindow row size.對(duì)于默認(rèn)XML導(dǎo)入,如果startrow提供, 第一個(gè)N(startrow -1)的元素都被跳過(guò), 其中 N是數(shù)據(jù)窗口行的大小。
For template XML import, if startrow is supplied, the first對(duì)于XML導(dǎo)入模板,如果startrow提供,首 ( startrow -1) occurrences of the repetitive row mapping defined in the template are skipped. (startrow -1)發(fā)生了重復(fù)的行映射模板中定義跳過(guò)。
|
endrow (optional) endrow(可選)
|
The number of the last detail row in the file that you want to copy.該文件要拷貝數(shù)的最后細(xì)節(jié)行中。 The default is the rest of the rows.默認(rèn)的是該行的其余部分。
For default XML import, if endrow is supplied, import stops when N * endrow elements have been imported, where N is the DataWindow row size.對(duì)于默認(rèn)XML導(dǎo)入,如果endrow提供,進(jìn)口停止當(dāng) N * endrow內(nèi)容已經(jīng)進(jìn)口的, 其中 N是數(shù)據(jù)窗口行的大小。
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.對(duì)于XML導(dǎo)入模板,如果endrow提供,該模板中定義導(dǎo)入后停止endrow行中出現(xiàn)的重復(fù)測(cè)繪已導(dǎo)入。
|
startcolumn (optional) startcolumn(可選)
|
The number of the first column in the file that you want to copy.匱乏的拷貝數(shù)列的第一個(gè)文件中的你。 The default is 1.默認(rèn)是1。
For default XML import, if startcolumn is supplied, import skips the first ( startcolumn - 1) elements in each row.對(duì)于默認(rèn)XML導(dǎo)入,如果startcolumn提供,進(jìn)口跳過(guò)第一(startcolumn - 1)在每個(gè)行元素。
This argument has no effect on template XML import.這一論點(diǎn)并沒(méi)有對(duì)模板的效果XML導(dǎo)入。
|
Returns返回
Long.長(zhǎng)。 Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:返回發(fā)生錯(cuò)誤的行的數(shù)目進(jìn)口,如果成功,它下面的一個(gè)負(fù)整數(shù),如果一:
-
-1 No rows or startrow value supplied is greater than the number of rows in the file -1沒(méi)有行或startrow值是文件大于供給的數(shù)量的行
-
-2 Empty file or input data does not match number of columns or required column type -2文件為空或輸入的數(shù)據(jù)類型不匹配的列數(shù)或要求列
-
-3 Invalid argument -3無(wú)效參數(shù)
-
-4 Invalid input -4輸入無(wú)效
-
-5 Could not open the file -5無(wú)法打開文件
-
-6 Could not close the file -6無(wú)法關(guān)閉文件
-
-7 Error reading the text -7錯(cuò)誤閱讀文本
-
-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解析錯(cuò)誤; XML解析器庫(kù)不存在或沒(méi)有很好形成的XML
-
-12 XML Template does not exist or does not match the DataWindow -12 XML模板不存在或不匹配的數(shù)據(jù)窗口
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.如果任何參數(shù)的值是 null, 返回 null ImportFile。如果可選importtype參數(shù)指定,而不是一個(gè)有效的類型,ImportFile返回-3。
Usage用法
The format of the file can be indicated by specifying the optional importtype parameter, or by including the appropriate file extension.該文件的格式,可通過(guò)指定可選的顯示importtype參數(shù),或通過(guò)包括適當(dāng)?shù)奈募U(kuò)展名。
For graph controls, ImportFile only uses three columns and ignores other columns.對(duì)于圖形控制,ImportFile只使用3列,而忽略其他列。 Each row of data must contain three pieces of information.每個(gè)數(shù)據(jù)行中必須包含三個(gè)信息件。 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.對(duì)于所有類型,除了散布圖,第一列從外地輸入的是該系列的名稱,第二列包含類,第三列包含的數(shù)據(jù)。
-
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.對(duì)于散布圖,第一列從外地輸入的是該系列的名稱,第二列是數(shù)據(jù)的x值,第三列是y值。
You can add data to more than one series by specifying different series names in the first column.您可以添加數(shù)據(jù)到多個(gè)系列的第一列指定不同的系列名稱研究。 To let users select the file to import, specify a null string for filename . PowerBuilder displays the Select Import File dialog box.為了讓用戶選擇要導(dǎo)入的文件, 文件名指定一個(gè)空字符串。PowerBuilder中顯示選擇導(dǎo)入文件對(duì)話框。
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. 雙引號(hào)雙數(shù)場(chǎng)引號(hào)中的位置和一個(gè)制表符分隔的文件影響到他們?nèi)绾翁幚頃r(shí),該文件是進(jìn)口的。 If a string is enclosed in one pair of double quotes, the quotes are discarded.如果字符串被雙引號(hào)括在一對(duì)的報(bào)價(jià)將被丟棄。 If it is enclosed in three pairs of double quotes, one pair is retained when the string is imported.如果是雙引號(hào)括在三對(duì),一對(duì)是保留字符串時(shí)是進(jìn)口的。 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.如果字符串引號(hào)括在雙兩對(duì),第一對(duì)被認(rèn)為是一個(gè)空字符串括起來(lái),而其余的字符串將被丟棄。
When there is a double quote at the beginning of a string, any characters after the second double quote are discarded.當(dāng)有一個(gè)雙引號(hào)的字符串開始時(shí),雙引號(hào)的所有字符后,第二次將被丟棄。 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.如果沒(méi)有第二個(gè)引號(hào),制表符分隔的返回字段是不承認(rèn)所有作為字段分隔符和字組成的一個(gè)運(yùn)輸?shù)南乱粋€(gè)出現(xiàn)的一個(gè)雙引號(hào),包括被認(rèn)為是字符串的一部分。 A validation error is generated if the combined strings exceed the length of the first string.驗(yàn)證錯(cuò)誤,如果合并生成字符串的字符串長(zhǎng)度超過(guò)了第一。
Double quotes after the first character in the string are rendered literally.雙引號(hào)字符的字符串字面呈現(xiàn)后的第一次。 Here are some examples of how tab-delimited strings are imported into a two-column DataWindow:這里有一些例子,說(shuō)明制表符分隔的字符串被導(dǎo)入到一個(gè)兩列的數(shù)據(jù)窗口:
Text in file文本文件
|
Result結(jié)果
|
"Joe" TAB "Donaldson" “喬”統(tǒng)計(jì)表“唐納森”
|
Joe Donaldson喬唐納森
|
Bernice TAB """Ramakrishnan"""伯尼斯統(tǒng)計(jì)表“”“萊瑪克里斯南”“”
|
Bernice "Ramakrishnan"伯尼斯“萊瑪克里斯南”
|
""Mary"" TAB ""Li"" “”瑪麗“”標(biāo)簽“,”禮“”
|
Empty cells空細(xì)胞
|
"Mich"ael TAB """Lopes""" “邁克”機(jī)場(chǎng)快線統(tǒng)計(jì)表“”“洛佩斯”“”
|
Mich "Lopes"邁克“洛佩斯”
|
"Amy TAB Doherty" “艾米統(tǒng)計(jì)表多爾蒂”
|
Amy<TAB>Doherty in first cell, second cell empty艾米<Tab>鍵多爾蒂在第一個(gè)單元格,第二個(gè)單元格為空
|
3""" TAB 4" 3“”“標(biāo)簽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. 指定一個(gè)文件名稱為空字符串 ,如果你指定一個(gè)空字符串為文件名 ,其余的參數(shù)被忽略。 All the rows and columns in the file are imported.文件的所有行和列的都是進(jìn)口的。
Examples范例
Example 1 示例1
This statement copies all the data in the file D:\EMPLOYEE.TXT to gr_employee starting at the first row:本聲明中的所有數(shù)據(jù)復(fù)制的文件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中的數(shù)據(jù)來(lái)自:\ EMPLOYEE.TXT開始,第2行第3列和行結(jié)尾的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.下面的語(yǔ)句是等價(jià)的。 Both import the contents of the XML file named myxmldata :這兩種導(dǎo)入XML文件的內(nèi)容命名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:這個(gè)例子使PowerBuilder中顯示指定文件導(dǎo)入對(duì)話框:
string null_str字符串null_str
SetNull(null_str) SetNull(null_str)
dw_main. ImportFile (null_str) dw_main。ImportFile(null_str)