Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CLIPWKS -Spreadsheet Library - exporting data to a spreadsheet http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Exporting Data To A Spreadsheet
------------------------------------------------------------------------------------------

Specifying Output FileName
    The first parameter is the name of the spreadsheet file to be created.
    It can be a file name or a fully qualified path and file desgignation.

Selecting Fields For Export
    By default, the Lexport() function will transfer every field into a
    cell of a new spreadsheet. This can be changed by specifying the
    second parameter, a field array. If passed, the field array will
    specify which fields and in which order they should be written to the
    spreadsheet.

        function demo
            local aList_ := {"Soc_Sec","Last","First","Salary"}
            select payroll
            Lexport("Payroll.wks", aList_)
        return nil

    The field array may contain a size designation, which is separated from
    the field name by chr(124). For example, if the third element in the
    example above were changed to:

        aList_[3] := "First | 1"

    Then column C of the spreadsheet would only contain the first character
    of field->first.

    The field reference can also contain embedded functions, for example:

        aList_[3] := "trim(last) + ',' + substr(first,1,1)"

    In the example above, the last name and the first intial would appear
    within the first column.

    If your array element conains a function rather than a field name, be
    sure to pass the size parameter. If not Lexport() will default to 10
    characters, which is the default width of a spreadsheet cell.

    NOTE:
    If headers are not desired in the spreadsheet, pass logical false as
    the third parameter to prevent headers from being written to the file.


Specifying Headers
    Lexport() will create column headers based on the field names. The
    third parameter, an array of headers, can be used to override the
    default headers.

Selecting Records
    The fourth parameter controls which records the Lexport() command
    should process. The default is all records.

    Options:

    ALL: Character string -- tranfer all records in the file.

    FOR: Expression -- only records meeting the filter expression.

    WHILE: Key, conditions -- seek the key, and do while condition is meet.

    TAG: A string the same number of characters as there are records in the
    database. If a check mark chr(251) is found in the corresponding
    position based on:

        substr( tag_list, recno(), 1 )

    the record will be written. If any other character is found, the record
    will not be transfered into the spreadsheet.

    EVERY: Every record is written into the spreadsheet. This allows a
    sample of the file to be extracted.

    If an array is passed as the parameter it is assumed to contain record
    numbers of the records to be transfered into the spreadsheet.


    Examples:

    Voters.dbf
            1.  Name        Character   25
            2.  Address     Character   25
            3.  City        Character   15
            4.  State       Character    2
            5.  Did_Vote    Logical      1
            6.  Party       Character    1


    To produce a spreadsheet of all voters with no headers, we would use
    the following syntax:

        Lexport( "voters.wks", aList_, .F., "ALL" )


    To produce a spreadsheet of only Republicans Party=="R", we would use
    the following sybtax:

        Lexport(  "voters.wks", aList_, .F., "FOR:party="R" )

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson