Реферат: Инструмент OLE

CONTEST:

1.Task for the laboratorywork.

2.Theory part.

2.1. Build-in FoxProw commands

2.2. OLE

3. Practical usage of data ofdata transfer.

4. Technical facilities &literature used.

5. Applications

1.Task for the laboratory work.

Theaim of this work is to show our ability to work with different Microsoftapplications & to produce the data exchange between them, using  build-incommands, OLE instruments & other possible facilities.

Inthe practical examples we will show the data transfer process using thefollowing Microsoft Applications: FoxPro, Excel & Word.

Alsoit is necessary to present the theory about the data transfer for it isimpossible to use all of them in the examples.    

 

2. Theory part.

There are several different ways to transferdata from FoxPro to different Microsoft Applications & vice versa.

2.1.Built-in FoxPro commands.

          Operatorcan use several built-in commands ofFoxPro such as Export, Import, Copy and Appendfrom.

          Now we would like to present somehelpful information about these operands.

          Theformat of EXPORT is:

EXPORT TO

          [FIELDS]

          []

          [FOR]

          [WHILE]

          [NOOPTIMIZE]

          [[TYPE]DIF | MOD | SYLK | WK1 | WKS | WR1 | WRK | XLS]]

Remarks

UseEXPORT to use FoxPro data in other software packages. 

Ifthe table/.DBF you are exporting from is indexed, the new file created iscreated in the indexed order.

Clauses

Includethe name of the file to which FoxPro exports data.  If you do not include an extension with thefile name, the default extension for the specified file type is assigned.

FIELDS

IncludeFIELDS to specify which fields are copied to the newfile.  If the FIELDS clause is omitted,all fields are copied to the new file. Memo and general fields are not copied to the new file even if theirnames are included in the field list.

The scopeclauses are:  ALL, NEXT ,RECORD , and REST.  These areexplained in the Overview of the FoxPro Language chapter in the FoxPro LanguageReference.  Commands which includeoperate only on the table/.DBF in the active work area.

Youcan specify a scope of records to copy to the new file.  Only the records that fall within the rangeof records specified by the scope are copied to the new file.

Thedefault scope for EXPORT is ALL records.

FOR

Ifthe FOR clause is included, only records that satisfy the logical conditionare copied to the new file. Including the FOR clause lets you conditionally copy records, filteringout undesired records. 

Rushmoreoptimizes an EXPORT… FOR command if is anoptimizable expression.  For bestperformance, use an optimizable expression in the FOR clause.  A discussion of Rushmore optimizableexpressions appears in the Optimizing Your Application chapter in the FoxProDeveloper's Guide.

WHILE

Ifthe WHILE clause is included, records are copied to the new file for as long asthe logical expression evaluates to true (.T.).

NOOPTIMIZE

Tocause Rushmore not to optimize EXPORT, include NOOPTIMIZE.  For more information, see SET OPTIMIZE andthe Rushmore discussion in the Optimizing Your Application chapter of theFoxPro Developer's Guide

.

TYPE

Youmust specify the type of file to be created. The TYPE key word is optional, but you must specify one of the followingfile types.

DIF

Whenyou specify DIF, each field from a FoxPro table/.DBF becomes a vector (column)and each record becomes a tuple (row) in a DIF (Data Interchange Format) file,used by VisiCalc.  The new file name isassigned a .DIF extension if an extension isn't included in .

MOD

Usethe MOD clause to export to a file in Microsoft Multiplan version 4.01 MODformat. The new file name is assigned an .MOD extension if you don't include anextension in .

SYLK

ASYLK file is a Symbolic Link interchange format (used by Microsoft Multiplan)in which each field from a FoxPro table/.DBF becomes a column in thespreadsheet and each record becomes a row. By default, SYLK file names have no extension.

WK1

Includethis option to create a Lotus 1-2-3 spreadsheet from a FoxPro table/.DBF.  A .WK1 extension is assigned to thespreadsheet file name for use with Lotus 1-2-3 revision 2.x.  Each field from the table/.DBF becomes acolumn in the new spreadsheet, and each record in the table/.DBF becomes aspreadsheet row.

WKS

ALotus 1-2-3 spreadsheet can be created from a FoxPro table/.DBF with thisoption.  A .WKS extension is assigned tothe spreadsheet file name for use with Lotus 1-2-3 revision 1-A.  Each field from the table/.DBF becomes acolumn in the new spreadsheet, and each record becomes a row in thespreadsheet.

WR1

Includethis option to create a Lotus Symphony spreadsheet from a FoxProtable/.DBF.  A .WR1 extension is assignedto the spreadsheet for use with Symphony version 1.01.  Each field from the table/.DBF becomes a columnin the new spreadsheet, and each record in the table/.DBF becomes a row in thespreadsheet.

WRK

ALotus Symphony spreadsheet can be created from a FoxPro table/.DBF with thisoption.  A .WRK extension is assigned tothe spreadsheet file name for use with Symphony version 1.10.  Each field from the table/.DBF becomes acolumn in the new spreadsheet, and each record in the table/.DBF becomes a rowin the spreadsheet.

XLS

IncludeXLS to create a spreadsheet you can use in Microsoft Excel.  Each field in the +selected table/.DBFbecomes a column in the spreadsheet; each table/.DBF record becomes a row inthe spreadsheet.  An .XLS file nameextension is assigned to the newly created spreadsheet file unless you specifya different extension.

          The format of IMPORT is:

IMPORT FROM

          [TYPE]

FW2 | MOD | PDOX | RPD | WK1 | WK3 | WKS | WR1 | WRK |XLS

As it shown in format (TYPE) there are many possible Microsoftapplications to import from to FoxPro but the meaning of these properties,description of which you can see in the previous chapter, that’s why it’s notnecessary to list all of them again. So we will mention those most commonused.   

Remarks

Mostsoftware packages store their data in a file format that cannot be openeddirectly in FoxPro.  IMPORT creates a newFoxPro table/.DBF from data stored in file formats that FoxPro cannot read.

Anew table/.DBF is created with the same name as the file the data is importedfrom.  A .DBF extension is assigned tothe newly created table/.DBF. 

Clauses

is the name of the file to import data from. If you don't include an extension with the file name, the defaultextension for the specified file type is assumed. 

TYPE

Thekey word TYPE is optional, but you must include one of the following file typesdescribed below.

PDOX

IncludePDOX to import Paradox files.  Databasefiles in Paradox versions 3.5 and 4.0 by Borland can be imported by includingthe PDOX option.

XLS

IncludeXLS to import data from Microsoft Excel spreadsheets versions 2.0, 3.0 and4.0.  Columns from the spreadsheet becomefields in the table/.DBF, and the spreadsheet rows become records in thetable/.DBF.  Spreadsheet files created inMicrosoft Excel have an .XLS extension.

Theformat of COPY is:

COPY TO

          [FIELDS]

          []

          [FOR]

          [WHILE]

          [[WITH]CDX] | [[WITH] PRODUCTION]

          [NOOPTIMIZE]

          [[TYPE][FOXPLUS | DIF | MOD | SDF | SYLK| WK1 | WKS | WR1 | WRK | XLS |

DELIMITED [WITH WITH BLANK | WITHTAB]]]

Remarks

Ifan index order is set, records are copied in master index order.

Clauses

Thename of the new file to which COPY TO copies data is specified with.  If you do not include anextension with the file name, the default extension for the specified file typeis assigned.  If you do not specify afile type, COPY TO creates a new table/.DBF and assigns the table/.DBF filename the default extension .DBF. 

FIELDS

Ifyou include FIELDS and a field list, you can specify which fields are copied tothe new file.  If the FIELDS clause isomitted, all fields are copied to the file. If the file you are creating is not a database, memo fields aren'tcopied to the new file even if memo field names are included in the field list.

Thescope clauses are:  ALL, NEXT, RECORD , and REST. These are explained in the Overview of the FoxPro Language chapter inthe FoxPro Language Reference.  Commandswhich include operate only on the table/.DBF in the active workarea.

Youcan specify a scope of records copied to a file.  Only the records that fall within the rangeof records specified by the scope are copied.

Thedefault scope for COPY TO is ALL records.

FOR

Ifthe FOR clause is included, only the records for which thelogical condition evaluates to true (.T.) are copied to thefile.  Include FOR toconditionally copy records, filtering out undesired records. 

Rushmoreoptimizes COPY TO with a FOR clause if is anoptimizable expression.  For bestperformance, use an optimizable expression in the FOR clause.  A discussion of Rushmoreoptimizable expressions appears in the Optimizing Your Application chapter inthe FoxPro Developer's Guide.

WHILE

IfWHILE is included, records are copied as long as the logicalexpression evaluates to true (.T.).

[WITH]CDX | [WITH] PRODUCTION

Ifthe table/.DBF you copy from has a structural index file, you can create astructural index file for the new table/.DBF. Including CDX or PRODUCTION creates an identical structural index filefor the new table/.DBF.  The tags andindex expressions from the original structural index file are copied to the newstructural index file.  The CDX andPRODUCTION clauses have the same effect.

Donot include CDX or PRODUCTION if you are copying to a file other than a newFoxPro table/.DBF.

NOOPTIMIZE

IncludeNOOPTIMIZE to cause Rushmore to not optimize COPY TO.  For more information, see SET OPTIMIZE orconsult the discussion of Rushmore optimization in the Optimizing YourApplication chapter in the FoxPro Developer's Guide.

TYPE

Ifthe file you are creating isn't a FoxPro table/.DBF, you must specify its filetype.  Although you must specify a filetype, you need not include the key word TYPE. You can create a wide variety of different file types includingDELIMITED ASCII text files in which you can specify a field delimiter.

FOXPLUS

FoxPromemo files have a different structure than FoxBASE+ memo files.  If your source FoxPro table/.DBF contains amemo field, include the FOXPLUS clause to create a table/.DBF that can be usedin FoxBASE+.  The FoxPro memo fieldcannot contain binary data because FoxBASE+ does not support binary data in memofields.

SDF

AnSDF (System Data Format) file is an ASCII text file in which records have afixed length and end with a carriage return and line feed.  Fields aren't delimited.  The SDF file name is assigned a .TXT fileextension if you do not include an extension.

SYLK

ASYLK file is a Symbolic Link interchange format (used in Microsoft MultiPlan)in which fields from the FoxPro table/.DBF become columns in the spreadsheetand records become rows.  SYLK file nameshave no extension.

DELIMITED[WITH | WITH BLANK | WITH TAB]

ADELIMITED file is an ASCII text file in which each record ends with a carriagereturn and line feed.  The default fieldseparator is a comma.  Since characterdata may include commas, character fields are additionally delimited withdouble quotation marks. 

Inthe following example there are 2 character fields («Smith» and«TELEPHONE») delimited with double quotation marks.  There is one numeric field which is notdelimited since numeric data does not contain commas.  The 3 fields are separated with commas.

«Smith»,9999999, «TELEPHONE»

TheDELIMITED WITH option can be used to replace the doublequotation marks with one of your choice.

Thecomma is not truly a delimiter.  However,the DELIMITED WITH BLANK or DELIMITED WITH TAB clauses allow you to replace thecomma field separator with either a space or a tab.  The data should not contain embedded spacesor tabs.

Youcannot combine the WITH clause with either the WITH BLANK orWITH TAB clauses.

Unlessyou specify otherwise, a .TXT extension is assigned to all newly createdDELIMITED files.

Theformat of APPEND is:

APPEND FROM | ?

          [FIELDS]

          [FOR]

          [[TYPE]    [DELIMITED [WITH TAB | WITH| WITH BLANK] |

DIF | FW2 | MOD | PDOX | RPD | SDF | SYLK | WK1 | WK3| WKS |

WR1 | WRK | XLS]]

Remarks

Thefile you are appending from is assumed to be a FoxPro table with a .DBFextension.  If the file you want toappend from is a FoxPro table and doesn't have a .DBF extension, you mustspecify its extension.  If the file is anot a FoxPro table, you must specify the type of file you append from. 

Beforeyou can append from a table created in dBASE IV that contains a memo field, youmust first open the table in FoxPro with USE. You are prompted with «Convert MEMO file to FoxProFormat?»  Choose Yes.

Ifyou append from a FoxPro table, the table you append from can be open inanother work area.  You can also appendfrom a table that isn't open but is available on disk and a shared table openedwhen SET EXCLUSIVE is OFF.  When thetable you append from contains records marked for deletion, the records are notmarked for deletion after they are appended.

Ifyou include the? clause instead of including a table name, the Open dialogappears so you can choose a table to append from.

Clauses

Specifythe name of the file to append from with .  If you don't include a file name extension,the default extension .DBF is assumed.

FIELDS

APPENDFROM supports an optional . Data is only appended to the fields specified in the field list.

FOR

Theentire source file is appended to the table unless you include the FORclause.  If the FOR clause is included, anew record is appended for each record in the file source for whichevaluates to a logical true (.T.). Records are appended until the end of the file is reached. 

TYPE

Ifthe file you are appending from isn't a FoxPro table, you must specify the fileTYPE.  Although you must specify the filetype, you need not include the key word TYPE. You can append from a wide variety of different file types includingDELIMITED ASCII text files in which you can specify a field delimiter.

Ifthe file you are appending from doesn't have the usual default file extensionfor that type of file, the source file name must include the file'sextension.  For example, Microsoft Excelspreadsheets normally have an .XLS file name extension.  If the spreadsheet you are appending from hasan extension other than the expected .XLS, be sure to specify the extension.

Caution   When appending from a spreadsheet, the datain the spreadsheet must be stored in a row major order rather than a columnmajor order.  This allows the appendedspreadsheet data to match the table structure.

DELIMITED[WITH TAB | WITH | WITH BLANK]

ADELIMITED file is an ASCII text file in which each record ends with a carriagereturn and line feed.  Field contents areby default assumed to be separated from each other by commas, and characterfield values to be additionally delimited by double quotation marks.  For example:

«Smith»,9999999, «TELEPHONE»

TheDELIMITED WITH TAB option can be used to specify files which contain fieldsseparated from each other by tabs rather than commas.  The DELIMITED WITH optioncan be used to indicate that character fields are delimited by a characterother than the quotation mark.  TheDELIMITED WITH BLANK option can be used to specify files which contain fields separatedby spaces instead of commas.  The fileextension is assumed to be .TXT for all delimited files.

Youcan import dates from delimited files if the dates are in proper dateformat.  The date format defaults to'mm/dd/yy'.  Including the centuryportion of a date is optional. FoxPro will import a date that includes thecentury.  If the century isn't includedin a date (for example '12/25/92'), the Twentieth century is assumed.  Date delimiters can be any non-numeric characterexcept the delimiter that separates the fields in the delimited file.

Datesin other formats can be imported if their format matches a date formatavailable in SET DATE.  To import datesthat are not in the default format, issue SET DATE with the proper date formatbefore using APPEND FROM.  To test if adate format can be successfully imported, use it with CTOD( ).  If the date is acceptable to CTOD( ), thedate will import properly.

FW2

FW2files are created by Framework II.  FW2file names are assumed to have a .FW2 extension.

RPD

RPDfiles are created by RapidFile version 1.2. RPD file names are assumed to have an RPD extension.

SDF

AnSDF (System Data Format) file is an ASCII text file in which records have afixed length and end with a carriage return and a line feed.  Fields are not delimited.  The file name extension is assumed to be .TXTfor SDF files.

WK3

Datafrom a Lotus 1-2-3 spreadsheet.  Eachcolumn from the spreadsheet becomes a field in the table; each spreadsheet rowbecomes a record in the table.  A .WK3file name extension is assigned to a spreadsheet created in Lotus 1-2-3revision 3.x.

2.2. OLE.

Anothermethod of data exchange between not only FoxPro but between all Windows basedapplications is OLE (OBJECT LINKING AND EMBEDDING)

Firstyou can use a FoxPro built in command Append General.

APPEND GENERAL FROM

          [LINK]

          [CLASS]

APPENDGENERAL is supported in FoxPro for Windows only.

Ifan OLE object already exists in the general field, it is replaced with the OLEobject from the file. 

Clauses

<generalfield>

Includeto specify the name of the general field the OLE objectis placed in.  You can specify a generalfield in a table open in a noncurrent work area by including the table aliaswith the field name.

Includeto specify the file containing the OLE object.  You must include the entire file name,including its extension.  If the file islocated in a directory other than the current default directory, include thepath with the file name.

LINK

IfLINK is included, a link is created between the OLE object and the file thatcontains the object.  The OLE objectappears in the general field but the object's definition remains in the file.  If LINK is omitted, the OLE object isembedded in the general field.

CLASS

Includethe CLASS clause to specify an OLE class for an OLE object other than thedefault class.

Tip   To determine the class for an OLE object,run REGEDIT and double-click on the OLE object. The class name is listed under Identifier. 

Youcan specify a class name when the file extension for the file containing theOLE object is different than the default extension and you want to force thebehavior for the class.  If the defaultextension can be used by multiple OLE servers, include the class to specify aparticular server.

3. Practical usage of data transfer.

Inapplications you can find the examples of the above mentioned commands usageand their results in different Microsoft Applications (FoxPro, Word &Excel).

4.Technical facilities & literature used.

During creating this program the followingequipment & software was used:

Pentium100 MHz PC with 8 Mb RAM

MicrosoftWindows’95

MicrosoftVisual FoxPro 3.0

MicrosoftWord 7.0

MicrosoftExcel 7.0

PrinterHewlett Packard LaserJet5L

No special literature but build-in HELP ofVisual FoxPro 3.0, Word 7.0, Excel 7.0 & useful advices was used to createthis laboratory work.

               

5. Applications.

Application1“Transferingdata form FoxPro to Word & Excel”

 

<img src="/cache/referats/433/image002.jpg" v:shapes="_x0000_i1025">

 

Application2 “FoxPro database converted to Excel (.xls) file”

 

<img src="/cache/referats/433/image004.jpg" v:shapes="_x0000_i1026">

Application3“FoxProdatabase converted to Word (.sdf) file”

<img src="/cache/referats/433/image006.jpg" v:shapes="_x0000_i1027">

Application4“FoxProbase converted in Word file — in Excel”

<img src="/cache/referats/433/image008.jpg" v:shapes="_x0000_i1028">

Application5“Excelfile in Word”

<img src="/cache/referats/433/image010.gif" v:shapes="_x0000_i1029">

еще рефераты
Еще работы по программированию, базе данных