Вы находитесь на странице: 1из 3

System iNetwork Head Nav Subscribe Log In Contact Us Advertise User login Username: * Password: * Request new password

Search Primary links Forums Archives Code Blogs Podcasts Webcasts e-Learning Guides Newsletters About Us Contact Us About the Network Tech Editor Profiles Editorial Calendar Writers Kit Advertise Join Network Categories RPG Programming Other Languages Application Development Database/SQL Availability Security Systems Management Networking IT Mgmt/Careers Site Links Solutions Store Events UK Centre Jobs System iPortal Home Content New Functions in XLPARSER4 Article ID: 57503Posted November 25th, 2008 in Other Languages Application Devel opment By:Scott Klement Q: I've been trying your XLPARSER4 utility to read Excel spreadsheets, but I hav e a problem. My subprocedures don't get called when a cell is empty. Since some empty 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. Excel keeps 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 be empty and therefore you can't use the last cell in the row to indicate that the entire row has been read. I've had that problem myself, so I decided to add some new functions to XLPARSER 4 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 y ou provide it with three subprocedures, one to be called when it finds a cell co ntaining character data, one to be called when it finds a cell containing numeri

c data, and one to be called when it finds a cell with a formula in it. If you h aven't used the tool previously or would like to refresh your memory, please rea d the most recent article about XLPARSER4. In this new update to XLPARSER4, you can provide two additional subprocedures to XLPARSER4. The XLPARSER4 service program calls these routines when a new row be gins 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 accept s two parameters: a subprocedure to call before each row begins, and a subproced ure to call when each row is complete. In the above example, the clear_struct() subprocedure is called when a row begin s. That procedure clears the contents of a data structure that will eventually c ontain 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 struct ure. Clear_struct() will be called only for rows that have data in the spreadshe et. The print_struct() subprocedure will be called when all the cells have been load ed for a particular row. It will be called only for rows that have data in the s preadsheet. In this example, print_struct() will be used to print the contents o f the data structure that contains one row. The Numeric, Character, and Formula subprocedures will be called when cells that contain Numeric, Character, and Formula data, respectively, are found. They wil l be called repeatedly in a loop for every cell found in the spreadsheet file. I n 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 des cribed in this article and all the sample programs from the previous articles fr om 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 Links POI Updated to Version 3.0.1 A General-Purpose Build Tool Retrieve Program Interface Information API Made Available with V5R4 PTF Set Use CGI Redirects To Launch Long URLs JDBC from RPG Enhancements ProVIP Sponsors ProVIP Sponsors Featured LinksSponsored Links Footer Site Links

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

Вам также может понравиться