Salesforce

How Do I Export Data into an HTML File? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Export Data into an HTML File? (Magic xpa 4.x)

You can use the DataViewToHTML() function to export data from your program into a text file. This function gives you, as the programmer, the most control over the export, so you can, if you choose, limit which records can be exported.

Using DataViewToHTML()

DataViewToHTML() will export the current data view, either in the current task or its ancestors. The syntax is:

DataViewToHTML(Generation, VariableList, HeaderList, TemplateFile, CharSet)

Where:

  • Generation is the task’s hierarchic position in the runtime task tree. Zero for the current task, 1 for the task’s parent, etc.

  • VariableList is a list of the variable names you want to export. This is the text name of the variable, as it appears in the Data View section of the task. The names are separated by commas (no spaces between variable names, and case matters).

  • HeaderList is a list of titles that will be used in the export file. In our example, we used “Studio Code” for the “Code” field, to make the output more readable. If the string is empty, no headers will be sent. If the string is ‘@’, the variable list will be used as the header list.

  • TemplateFile is the name of a template file that can be used to create the HTML file (optional).

  • CharSet is a number that sets the character set to be used: 0=ANSI, 1=Unicode, 2=UTF-8.

The result from our sample is shown below.

Using the HTML Template File

If you want, you can specify an HTML template file when you export your data. The HTML template file needs to follow the format of the minimal HTML file shown on the left. The <MGTABLE> tag will be replaced during the export with the HTML table text.

Minimal template

Customized template

This is the minimum template. <MGTABLE> will be replaced at runtime with the actual table.

Here is our customized template. We’ve added some meta tags, and more importantly, a link to a stylesheet.

MGTABLE Styles

The <MGTABLE> tag has two style tags you can use in your template, RowStyle and ColumnStyle. These determine how the style tags are attached to the generated table.

RowStyle:

All

Magic xpa creates a specific style for each row and title.

EvenAndOdd

Magic xpa creates two styles, an MG_Even_Row and an MG_Odd_Row.

Equal

Magic xpa creates the same style for all rows and titles.

Column Style:

All

Magic xpa creates a specific style for each column.

Equal

Magic xpa creates the same style for all columns.

So in our example, we get an HTML table that looks like the one below. Note all the class= tags. You can use those to customize the look of the table.

Here is a customized version of our DVD list in HTML.

See also

The Online and Rich Client Samples projects (program RP02 and RRP02)

Reference
Attachment 
Attachment