Re: ViaDuct (Pick to Excel) download -
12-02-2005
, 03:20 PM
I've copied some documentation for you as well as a sample program
Viaduct provides. Hope this helps.
Excel Integration
The callable subroutine VTW.FILL.EXCEL allows your programs to populate
a Microsoft Excel document with data from your host system.
VTW.FILL.EXCEL will replace "bookmarks" in your Excel spreadsheet with
data passed to it. These bookmarks can be either the names of
formulas, or spreadsheet cell locations in the form "RxCy", where "x"
is the row number and "y" is the column number (for example, "R3C4" is
the cell at row 3, column 4). Your program should pass the "bookmark
list" and "value list" as attribute-mark delimited lists of bookmarks
and replacement values.
Note that VTW.FILL.EXCEL will attempt to start MS Excel if it is not
already running. If you do not have the directory where MS Excel is
located in your PC path, however, it may not be possible to start it
automatically. Your program can call the VTW.START.EXCEL subroutine,
passing it the full path to the MS Excel executable, if VTW.FILL.EXCEL
cannot start the program automatically. Alternatively, you can
manually start Excel before calling VTW.FILL.EXCEL.
To use the VTW.START.EXCEL subroutine, please use the following syntax:
CALL VTW.START.EXCEL(FULLPATH, STATUS)
FULLPATH is the full pathname to the MS Excel executable (EXCEL.EXE).
The STATUS variable is set to "0" if successful, or a negative error
value.
To use the VTW.FILL.EXCEL subroutine, please use the following syntax:
SUBROUTINE VTW.FILL.EXCEL(PCFILE, BOOKMARK.LIST, VALUE.LIST, PRINTFLAG,
NEWPCNAME, CLOSEFLAG, STATUS)
PCFILE is the full path name to your spreadsheet, or "" to use the
blank spreadsheet Excel normally opens. BOOKMARK.LIST and VALUE.LIST
are the attribute-mark delimited lists of bookmarks and replacement
values, respectively. If BOOKMARK.LIST is "", VTW.FILL.EXCEL will fill
the spreadsheet in row and column order for each attribute and value in
VALUE.LIST (that is, each attribute in VALUE.LIST will be a new row in
the spreadsheet, and each value in each attribute will be a column in
the spreadsheet). Set PRINTFLAG to "1" if you wish to print the
spreadsheet after replacing the bookmarks, or "0" otherwise. If you
wish to save the spreadsheet after replacing the bookmarks, set
NEWPCNAME to the full path name you wish to save the document to,or set
it to "" otherwise. If you wish to have MS Excel shut down after
replacing the bookmarks, set CLOSEFLAG to 1, or set CLOSEFLAG to 0 to
keep Excel open. The STATUS variable will be set to "0" if all
operations are successful, or a negative error code.
Demonstration Program
EXCEL.DEMO1
001 !* 16NOV100 11:29:50
002 * Demonstration program for VTW.FILL.EXCEL
003 *
004 * IF EXCEL IS NOT IN YOUR PATH, MAKE SURE YOU CAN START IT
005 EXCEL.LOCN="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\EXCEL.EXE"
006 OPEN "DICT","PCPROGS" TO DICT.FL THEN
007 READV EXCEL.LOCN FROM DICT.FL, 'CONFIG', 2 ELSE
008 EXCEL.LOCN="C:\PROGRAM FILES\MICROSOFT
OFFICE\OFFICE\EXCEL.EXE"
009 END
010 END
011 CALL VTW.START.EXCEL(EXCEL.LOCN, STATUS)
012 IF STATUS <> "0" THEN
013 PRINT "Could not start EXCEL!"
014 STOP
015 END
016 BOOKMARK.LIST = ""
017 VALUE.LIST = ""
018 *
019 * BUILD LIST OF WHICH BOOKMARKS IN YOUR EXCEL SPREADSHEET YOU WISH
TO REPLA
CE,
020 * AND THE VALUES YOU WISH TO REPLACE THEM WITH
021 * OR LEAVE BOOKMARKS SET TO NULL IF YOU WISH TO SEND A DYNAMIC
ARRAYOF VALUES
022 *
023 FOR EACH.ROW=1 TO 10
024 FOR EACH.COL=1 TO 5
025 VALUE.LIST<EACH.ROW,EACH.COL>=EACH.ROW*10+EACH.COL
026 NEXT EACH.COL
027 NEXT EACH.ROW
028 *
029 * SET PRINTFLAG TO 1 TO PRINT THE DOCUMENT
030 PRINTFLAG = 0 ;* DO NOT PRINT THIS DOCUMENT
031 *
032 * SET NEWXLS TO THE FULL PATH NAME YOU WISH TO SAVE THIS DOCUMENT
UNDER
033 NEWXLS = "" ;* DO NOT SAVE TO A NEW SPREADSHEET
034 *
035 * STATUS VARIABLE VALUE IS SET TO 0 (IF OKAY), OR < 0 IF ERROR
036 STATUS = ""
037 *
038 * FULL PATH TO EXCEL SPREADSHEET THAT SERVES AS OUR 'TEMPLATE' IS
PASSED
039 * AS PARAMETER #1
040 SRCXLS = "C:\WORKING\VTWSAMPLE.XLS"
041 *
042 * SET CLOSEFLAG TO 1 IF YOU WANT APPLICATION TO SHUT DOWN
043 CLOSEFLAG = 0
044 *
045 CALL VTW.FILL.EXCEL(SRCXLS, BOOKMARK.LIST, VALUE.LIST, PRINTFLAG,
NEWXLS, CLOSEFLAG, STATUS)
046 *
047 IF STATUS < 0 THEN
048 PRINT "Error: Excel Demo failure (":STATUS:")"
049 END
050 *
051 END |