Presentation is loading. Please wait.

Presentation is loading. Please wait.

® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files.

Similar presentations


Presentation on theme: "® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files."— Presentation transcript:

1 ® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files from a program. It assumes you understand EGL projects, the language, tools, build-files and statements used to access serial files.

2 2 Last update: 12/04/2007 Reading/Writing an MS-Excel Spreadsheet (.csv) File  Let’s say that you needed to write an MS-Excel spreadsheet using EGL. Here are the steps:  Create a page that allows users to search for orders from a customer. Then subsequently, select orders and write the data to a comma-delimited (spreadsheet) file. Your JSFHandler will contain:  Create a new record of type: CSVRecord – which contains a reference to a Resource Association logical name for the.CSV filespec  EGL/SQL search logic (explicit/custom SQL)  EGL write logic to read and/or write to an external file  Modify the Resource Association element for the external file  Logical (internal) name  File type  (Physical) file name/file spec  Run the page  The detailed steps begin on the next slide. Note that we will be combining writing a.CSV file with some fairly intense JSF dataTable work. Set aside the appropriate period of time  Note – see the product help on the topic: CSVRecord stereotype – for detailed information on the CSVRecord properties

3 3 Last update: 12/04/2007 Writing to a.CSV File – 1 of 7  Here’s what we’re going to be doing with this workshop  This page will allow users to search for any customer’s orders Then select one or more orders To write to a.CSV file

4 4 Last update: 12/04/2007 Create the page and JSFHandler – 2 of 7  Create the page and JSFHandler – 2 of 7 csvRecPage.jsp  Create a new,.JSP web page, named: csvRecPage.jsp Notes  Copy/Paste the code in the ***Notes section of this slide – and read the comments. Observe the following: CSVRecord 1.The CSVRecord declaration – note that the screen capture is cut-off, and does not show all the comments, and code in the Notes section. sel int[0] Orders 2.The sel int[0] array is a dynamic array that will (at run-time) contain the index values of the Orders – for every row the user checks (checkbox control – U.I. technique shown on an upcoming slide) Orders sel 3.The loop shows how to reference the selected Orders rows – by using the sel array’s occurrences - note the nested array brackets “shorthand” Ctrl/S  Ctrl/S – save your code 2. 3. 1.

5 5 Last update: 12/04/2007 – 3 of 7  Create the default dataTable and other Controls – 3 of 7 orders (From Page Designer/Page Data view) Drag and Drop orders on the page – and create the dataTable shown below - display all of the fields in the record – as Read/only (output) controls  Drag and Drop searchCustID – make it an Input field  Drag and Drop the getOrders() function – next to the field (by placing it inside the dotted line border)  Drag and drop the writeOrders() function – below the JSF dataTable

6 6 Last update: 12/04/2007 Modify the dataTable’s U.I. Properties – 4 of 7  Modify the dataTable’s U.I. Properties – 4 of 7 From Page Designer, select the entire dataTable (note – the easiest way to select the entire dataTable is to click on a column, and press the up arrow key twice on your keyboard) From the hx:dataTableEx properties – give the control a Border: 1 From – Display options Delete Column classes:

7 7 Last update: 12/04/2007 Add a selection column to the table – 5 of 7  Add a selection column to the table – 5 of 7 From - Row actions:  Click: Add selection column to the table  A new column will be added to your dataTable with a small checkbox inside it, representing the selection row action, and your Properties should show:  Value:  From: Value: click the Browse… icon sel – int[]  Select the sel – int[] array OPTIONAL  Click: Add selection toolbar  Click: Add selection combo box

8 8 Last update: 12/04/2007  Add a new Association to the Resource Association – 6 of 7 As you did in the previous workshop(s): EGLWeb.eglbld - Add a new Resource Association to the EGLWeb.eglbld build file. orders - Add a File Name for orders – and point it to a systemName. - - From the EGLWeb.eglbld file, select your resource associations part, as the resourceAssociations for the build file Generate your project

9 9 Last update: 12/04/2007  Run the Program – 7 of 7  Run the page  Search for a Customer with orders  Select (check) some orders to add to the.CSV file  Click writeOrders  From MyComputer, open the.CSVFile

10 10 Last update: 12/04/2007  Now that you have completed this topic, you should be able to:  List several of the EGL record types used for accessing external files  Define the purpose of the following EGL system files  Build file  Resource Association Part  Linkage Part  Create a new Resource Association to define an external file for EGL access  Write and Debug an EGL program that used external data access statements to read and write external files  Define a serialRecord for an external file Topic Summary


Download ppt "® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files."

Similar presentations


Ads by Google