Repository navigation
downloadFileFromQuery
Julian Halliwell edited this page Sep 20, 2021
·
12 revisions
Provides a quick way of downloading a spreadsheet to the browser by passing in a query and a filename. The query column names are included by default as a bold header row.
downloadFileFromQuery( data, filename[, addHeaderRow [, boldHeaderRow [, xmlFormat [, contentType [, streamingXml [, streamingWindowSize [, ignoreQueryColumnDataTypes [, datatypes ] ] ] ] ] ] ] ] )
-
dataquery: the data you want to download -
filenamestring: name of the file to download, without the file extension
-
addHeaderRowboolean default=true: whether to include the query column names as a header row -
boldHeaderRowboolean default=true: whether to make the header row bold -
xmlFormatboolean default=false: whether to create an XML spreadsheet (.xlsx) -
contentTypestring default="application/msexcel" OR "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": specify if you wish, otherwise an appropriate MIME type for the spreadsheet will be used -
streamingXmlboolean default=false: whether to create a memory-efficient streaming XML spreadsheet -
streamingWindowSizeinteger default=100: (positive integer greater than 0) the maximum number of rows that are kept in memory at once while populating a streaming spreadsheet, before being flushed to disk. -
ignoreQueryColumnDataTypesboolean default=false: whether to ignore the query column data types (e.g.VarChar) and auto-detect each cell type from the value. -
datatypesstruct: specify data types as keys and the columns they should apply to in your data as an array of column names or (positional) numbers. These types will override the query column types or auto-detection where possible. Possible data type keys are:string,numeric,date,time,boolean,auto. See addRows() for examples.
Chainable? No.
spreadsheet = New spreadsheet();
data = QueryNew( "First,Last","VarChar,VarChar",[ [ "Susi","Sorglos" ],[ "Frumpo","McNugget" ] ] );
filename = "report";
spreadsheet.downloadFileFromQuery( data,filename );