EP 6.1 lets you create portlet elements that are based on files. The file must contain data arranged in a format that can be mapped to grid data (see “Grid rule enhancements”), for example:
Delimited columns – a file that has data separated by commas, tabs, semi-colons, colons, or spaces. Typically, this is a file with a .csv extension, which you can create when you save the contents of a spreadsheet application.
Fixed size columns – a file with data arranged in columns of a fixed size. These files can be saved and uploaded with a .txt extension.
Using either file type, you can create a portlet element that uses the grid-rule functionality of Enterprise Portal.
Creating a delimited file element
This example shows how to create a portlet from a file source that uses commas to separate the data. You can also create a file that uses tabs, semi-colons, colons, or spaces to separate data.
Use a spreadsheet application to create a four column table in a spreadsheet program with the following content:
Col1 |
Col2 |
Col3 |
Col4 |
---|---|---|---|
1 |
2 |
3 |
4 |
999 |
888 |
777 |
666 |
Save the content as a comma-delimited file in a temporary directory, with the name data.csv; for example, C:\temp\data.csv.
Log in to Web Studio, select Build Portlets, select New from the Portlet Manager Status menu, then click New to launch Portlet Builder.
Click the arrow to the right of the Add button and select File Element. You see the New Element window, which allows you to identify the file to upload from your local machine to the Enterprise Portal server.
Complete the File Element Definition options:
Delimited, Fixed Width – reflects how source file content is arranged—data separated by a delimiter (such as a comma), or data arranged in fixed-sized columns. See “Creating a file element with fixed-column data” on page 8.
For this example, select Delimited.
File Name – enter the file name of your source data; for example, C:\TMP\data.csv, or click Browse to locate the file.
Destination Location – accept the default location, which is created automatically.
The second File Name field is automatically filled in
once you upload the file.
Delimiter – select the delimiter used in the source data file. For example, select “Comma” if commas are used to separate columns of data.
Merge Repeated Delimiters – whether repeated delimiters should be replaced with a single delimiter. This is useful if your source data includes blank columns.
Text Quoter – specifies the quote character that is used to define a section of “as is” text that may include delimiters.
Click Upload to the right of the Destination Location field. When the confirmation displays that the file was successfully uploaded, click OK.
Click Preview to see the result.
Click Next.
In the next three windows, click Next to bypass the fields, which are not necessary for this example, or use the regular grid-rule, record layout, and filter steps to define the data format. See the Enterprise Portal Developer’s Guide, Chapter 4, in the section called “Building Portlets,” for more information.
In the Window Preview window, enter a name for the file element. Click Next.
In the Continuous Capture window, click Finish.
In the Portlet Builder, click Save, complete the options, then click Finish.
Creating a fixed-column file element
This section describes how to create a file element using fixed column width data; that is, the source file data is arranged in columns of fixed length.
Use a text editor to create a four column table with the following content:
Col1 |
Col2 |
Col3 |
Col4 |
---|---|---|---|
1 |
2 |
3 |
4 |
99 |
44 |
1 |
12 |
Verify that the number of spaces between each column is the same; for example “9.”
Format the text using a monospaced font—for example, Lucinda Console.
Save the content as a text file (*.txt) in a temporary directory, with the name data.txt; for example, C:\temp\data.txt. Exit the text editor.
Log in to Web Studio.
Select Portlets from the Build menu in the left pane, select New from Portlet Manager Status menu, then click the New button to launch Portlet Builder.
Click the arrow to the right of the Add button and select File Element. You see the New Element window, which allows you to identify the file to upload from your local machine to the Enterprise Portal server.
Complete the File Element Definition options:
Delimited, Fixed Width – reflects how the source file content is arranged—data separated by a delimiter (such as a comma), or data arranged in fixed-sized columns.
For this example, select Fixed Width.
File Name – enter the file name of your source data, for example, C:\temp\data.txt, or click Browse to locate the file.
Destination Location – accept the default location, which is created automatically.
The second File Name field is automatically filled in
once you upload the file.
Columns (comma separated) – the starting
point of each column in the data file. For example, 0,
9, 18, 27
means that each of the columns in the
data file starts at those positions.
Click Upload to the right of the Destination Location field. This shows the user name you logged in with, for example “opsuper.” The program uploads the file under documentroot (the default is temp\PortalDocs). The file you upload is saved in a subdirectory beneath temp\PortalDocs that has your user name; for example:
x:\temp\PortalDocs\opsuper
where “x” is the drive where the temporary directory is located, and “opsuper” is the name of the user that uploaded the file.
When the confirmation displays that the file was successfully uploaded, click OK.
Click Preview to see the result.
Click Next.
In the next three windows, click Next to bypass the fields, which are not necessary for this example, or use the regular grid-rule, record layout, and filter steps to define the data format. See the Enterprise Portal Developer’s Guide, Chapter 4, in the section called “Building Portlets,” for more information.
In the Window Preview window, enter a name for the file element.
In the Continuous Capture window, click Finish.
In the Portlet Builder, click Save, complete the options, then click Finish.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |