Get a Jumpstart with our Sample Apps
Results 1 to 3 of 3

Thread: Help with Import Excel Genie

  1. #1
    Member
    Real Name
    Larry mandras
    Join Date
    Nov 2010
    Posts
    89

    Default Help with Import Excel Genie

    I have a web application that I am building. I want to use the Import Excel Genie to import data from the user and then update the data in the temporary dbf table it creates. The one challenge is I need to get field value that is on the grid and update a column in the temp dbf. How can I set this as a session variable? Also, I want to perform updates on two other columns that would be derived from a select statement against my backend MQSQL database.

    I looked for documentation on this Genie/Feature pack but was not able to find anything.

    I copied the function prototype, but not sure I am heading in the right direction.

    Code:
    function upZips as v (e as p)
    This function is called after the Excel or Ascii file has been uploaded to the server, but before the data is imported into the target table.
    'It allows you to validate the data before it is imported.
    'The uploaded file is imported into a temporary .dbf table. Your function can loop over all of the records in 
    'the temporary .dbf table and make any changes to the data that you want, including deleting records and inserting new records.
    
    'The 'e' object that is passed in contains:
    'e.inputFilename - the name of the temporary .dbf table that your function will process
    
    'Your function must set these variables:
    'e.outputFilename - the name of the temporary .dbf table that contains the data to be imported into the target table.
    '(If e.outputFile is not set, then it is assumed to be the same as e.inputFilename)
    'e.abort -  (Optional) Set to .t. or .f.. If e.abort is set to .t. then the data is not imported and the error message defined in e.errorText is displayed to the user.
    'e.errorText - Must be set if e.abort = .t.. The error message to display to the user.
    
    
    'The passed in 'e' object contains these additional properties:
    
    'e.rv  - Request variables
    'e.tmpl - pointer to the Grid definition
    'e.rtc - a pointer variable that contains run-time calculations
    'e.__si - state information
    'e.session  - session variables
    
    'If you want to send any Javascript back to the browser to execute after this event has completed, you can set this property:
    'e.javascript 
    
    'EXTREMELY IMPORTANT - The Javascript that is sent back to the browser is executed in the context of IFrame that contains the File Select window.
    'Therefore, in order for the Javascript you send back to invoke methods of the Grid object, you must prefix all methods with 'window.parent'.
    'For example: window.parent.{grid.object}.refresh()
    
    'Sample validate code - delete records where the quantity is > 10:
    'dim t as p
    't = table.open(e.inputFilename)
    ''If you turn on batch begin, scripts that loop over records in a table are significantly faster
    't.batch_begin()
    '
    'dim i as n 
    'dim count as n 
    'count = t.records_get()
    'for i = 1 to count 
    '    if t.quantity > 10 then 
    '        t.change_begin()
    '        t.delete()
    '        t.change_end(.t.)
    '        'After deleting a record, the record pointer automatically moves to the next record.
    '        'So, no need to advance the record pointer!
    '    else
    '        t.fetch_next()
    '    end if 
    'next i 
    '
    ''Call batch end
    't.bach_end()
    't.close()
    
    t = table.open(e.inputFilename)
    ''If you turn on batch begin, scripts that loop over records in a table are significantly faster
    t.batch_begin()
    '
    dim i as n 
    dim count as n 
    count = t.records_get()
    for i = 1 to count 
        if t.quantity > 10 then 
            t.change_begin()
            vrZip_code = t.zip_code
            sql = ""
            
            
            
            t.zip_code = zip_id
            t.change_end(.t.)
            'After deleting a record, the record pointer automatically moves to the next record.
            'So, no need to advance the record pointer!
        else
            t.fetch_next()
        end if 
    next i 
    
    ''Call batch end
    t.bach_end()
    t.close()
    
    
    
    end function

  2. #2
    Member
    Real Name
    John Haytko
    Join Date
    Dec 2007
    Posts
    94

    Default Re: Help with Import Excel Genie

    Did you ever figure this out? I'm needing to "set" e.outputFilename. I'm unable to find any documentation on the method for setting the dot variable....

  3. #3
    Member
    Real Name
    John Haytko
    Join Date
    Dec 2007
    Posts
    94

    Default Re: Help with Import Excel Genie

    Okay....love the xbasic debug.

    This worked for me. Not sure this is how they intended it but it works.

    fqn = table.actual_filename_get(e.inputFilename)
    e.outputFilename = strtran(fqn, "__temp.dbf", "__temp1.dbf")

    This got me an e.outputFilename that I would re-arrange the fields in and then copy the records to it. 18 hrs later... :(

Similar Threads

  1. Import Genie won't allow choosing Excel file
    By Mike Wilson in forum Alpha Five Version 10 - Desktop Applications
    Replies: 3
    Last Post: 11-11-2010, 03:45 PM
  2. ADO Import Genie not work with Excel
    By russ Boehle in forum Alpha Five Version 7
    Replies: 5
    Last Post: 03-09-2006, 09:39 PM
  3. Import Genie problem with Excel
    By Dick Krause in forum Alpha Five Version 5
    Replies: 4
    Last Post: 08-15-2003, 03:50 PM
  4. Import error ODBC Genie & Excel
    By Jo Hulsen in forum Alpha Five Version 5
    Replies: 6
    Last Post: 08-06-2003, 06:39 AM
  5. Excel error "Alpha Five ODBC Import Genie&quo
    By Tala Nykola in forum Alpha Five Version 5
    Replies: 1
    Last Post: 02-12-2003, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •