New Functions in XLPARSER4

Embed Size (px)

Citation preview

  • 7/27/2019 New Functions in XLPARSER4

    1/3

    System iNetwork Head NavSubscribe Log In Contact Us AdvertiseUser loginUsername: *Password: *

    Request new passwordSearch

    Primary linksForums Archives Code Blogs Podcasts Webcasts e-Learning Guides Newsletters AboutUs Contact Us About the Network Tech Editor Profiles Editorial Calendar WritersKit Advertise Join Network

    CategoriesRPG ProgrammingOther LanguagesApplication DevelopmentDatabase/SQLAvailabilitySecurity

    Systems ManagementNetworkingIT Mgmt/CareersSite LinksSolutionsStoreEventsUK CentreJobs

    System iPortal Home ContentNew Functions in XLPARSER4Article ID: 57503Posted November 25th, 2008 in Other Languages Application DevelopmentBy:Scott KlementQ: I've been trying your XLPARSER4 utility to read Excel spreadsheets, but I have a problem. My subprocedures don't get called when a cell is empty. Since someempty cells occur at the end of a row, how can I tell when a row is complete?

    A: XLPARSER4 skips empty cells because they don't exist in the Excel file. Excelkeeps the size of the XLS file to a minimum by not storing empty cells on disk.You're right that this behavior makes it challenging to keep track of when a ne

    w row begins or ends, because it's possible that the last cell in a row will beempty and therefore you can't use the last cell in the row to indicate that theentire row has been read.

    I've had that problem myself, so I decided to add some new functions to XLPARSER4 to help you detect when an entire row is complete.

    If you've been using my XLPARSER4 utility to read a spreadsheet, you know that you provide it with three subprocedures, one to be called when it finds a cell containing character data, one to be called when it finds a cell containing numeri

  • 7/27/2019 New Functions in XLPARSER4

    2/3

    c data, and one to be called when it finds a cell with a formula in it. If you haven't used the tool previously or would like to refresh your memory, please read the most recent article about XLPARSER4.

    In this new update to XLPARSER4, you can provide two additional subprocedures toXLPARSER4. The XLPARSER4 service program calls these routines when a new row begins or ends, respectively.

    For example, your program might start like this:

    xlparse_notify( %paddr(clear_struct): %paddr(print_struct) );

    xlparse_workbook( '/tmp/november_sales.xls': %paddr(Numeric): %paddr(Character): %paddr(Formula) );

    The xlparse_notify() subprocedure is the one I added for this article. It accepts two parameters: a subprocedure to call before each row begins, and a subprocedure to call when each row is complete.

    In the above example, the clear_struct() subprocedure is called when a row begins. That procedure clears the contents of a data structure that will eventually contain one row-full of data from the spreadsheet. Because this data structure wi

    ll be cleared before every row, any empty cells will be empty in the data structure. Clear_struct() will be called only for rows that have data in the spreadsheet.

    The print_struct() subprocedure will be called when all the cells have been loaded for a particular row. It will be called only for rows that have data in the spreadsheet. In this example, print_struct() will be used to print the contents of the data structure that contains one row.

    The Numeric, Character, and Formula subprocedures will be called when cells thatcontain Numeric, Character, and Formula data, respectively, are found. They will be called repeatedly in a loop for every cell found in the spreadsheet file. In the sample program, they're used to load data into the data structure that wil

    l eventually be printed by the print_struct() routine.

    You can download the updated copy of XLPARSER4 as well as the sample program described in this article and all the sample programs from the previous articles from the following link:http://www.pentontech.com/IBMContent/Documents/article/57503_795_XlParse.zip

    Bookmark/Search this post with:Login to post comments Email this page Printer-friendly version Related

    LinksPOI Updated to Version 3.0.1A General-Purpose Build ToolRetrieve Program Interface Information API Made Available with V5R4 PTF Set

    Use CGI Redirects To Launch Long URLsJDBC from RPG Enhancements

    ProVIP Sponsors

    ProVIP Sponsors

    Featured LinksSponsored LinksFooter Site Links

  • 7/27/2019 New Functions in XLPARSER4

    3/3

    Home Subscribe Now Advertise Contact Us Feedback Terms & Conditions Trademarks Privacy Policy Copyright Penton Media