DownloadToExcel function

Syntax

DownloadToExcel(&Rowset, File_Name, Output_Format, [Header_Required])

Description

Use the DownloadToExcel function to generate a spreadsheet file with data as specified by the rowset object, and download it locally to the end-user’s machine. You can specify the following file formats for the spreadsheet file - XLSX, HTML, or CSV.

Parameters

Parameter Description

Rowset

Specify an already instantiated and populated rowset object containing the result.

File_Name

Specify a name for the spreadsheet file, which is generated and downloaded to the user’s machine.

Output_Format

Specify the format of the output. You can specify either a numeric value or a constant value.

Header_Required

Specify whether the spreadsheet header should be displayed or not. This parameter takes a Boolean value. This parameter is optional.

The values for Output_Format values can be as follows:

Numeric Value Constant Value File Format

1

%ExcelFormat_Xlsx

XLSX

2

%ExcelFormat_Html

HTML

3

%ExcelFormat_Csv

CSV

Returns

Returns 0 if the function is successful; returns 1 if the function is unsuccessful.

Example

Local Rowset &rs;
&rs = CreateRowset(Record.QE_ABSENCE_HIST);
/*Populate Rowset*/
&NUM_READ = &rs.Fill();
&File_Name = "output-" | %Datetime | ".csv";
/*Download the result into spreadsheet file and push it to the web browser*/
&result = DownloadToExcel(&rs, &File_Name, %ExcelFormat_Csv);