Present Data in Multi-Column Report Layout

l  Problem

This is a problem about report development. With this example, the flexible computation mechanism of esProc can be fully demonstrated. esProc is even capable of handling the reports requiring irregular layouts.

The problem is pretty simple: to change the layout of the following Names table to display data in 3 columns, namely, name1, name2, and name3. It is also expected that the code can also easily enable us to rearrange the table in columns of any number if possible.

72

 

l  Tip

General steps: You can use esProc record function to get this done.

1. Use the record function to write the name sequence to a new table.

 

l  Code

 

A

 

1

=file("C:\\txt\\Names.txt").import@t().(name)

Convert values of name field to a sequence

2

=create(name1,name2,name3)

Create the multi-column target table

3

=A2.record(A1)

Write A1 into A2’s table using record function

 

With this piece of code, if you want to display data in more columns, you can simply write the desired structure in cell A2and the names will be populated according to the new structure.

 

l  Result