Menu
Download Free Trial
Table of contents

exportTo

exportTo(type:String, params:Object, callbackHandler:Function|String)

[starting from version: 1.4]

Exports grid or chart to CSV, HTML, PDF, Image or Excel format. The file can be saved to the local file system or to your server (you need to have a script on the server side).

Parameters

  • type – type of export. There are such types available: "csv", "html", "pdf", "image" and "excel".
  • params (optional) – export parameters. Object params can contain the following properties:
    • filename – default name of the resulting file.
    • destinationType – defines where the component’s content will be exported. Destination type can be the following:
      • "file" – the component’s content will be exported to the file to the local computer.
      • "server" – the component’s content will be exported to the server (a server-side script is required).
    • excelSheetName (starting from v2.2) (optional) – String. To configure the sheet name when exporting to Excel file.
    • footer (starting from v2.211) (optional) – String. HTML and PDF only. Footer is set in HTML format (tags, inline styles, img with base64 src). For PDF it is rendered in the browser and added as an image to the exported file. The following tokens can be used for PDF export: ##CURRENT-DATE##, ##PAGE-NUMBER##. They will be replaced by appropriate data. ##CURRENT-DATE## is also available for HTML export.
    • header (starting from v2.211) (optional) – String. HTML and PDF only. Header is set in HTML format (tags, inline styles, img with base64 src). For PDF it is rendered in the browser and added as an image to the exported file. The following tokens can be used for PDF export: ##CURRENT-DATE##, ##PAGE-NUMBER##. They will be replaced by appropriate data. ##CURRENT-DATE## is also available for HTML export.
    • pageOrientation (optional) – defines the page orientation for a PDF file. Page orientation can be the following:
      • "portrait" (by default) – defines portrait page orientation for a PDF file.
      • "landscape" – defines landscape page orientation for a PDF file.
    • showFilters (starting from v2.1) (optional) – Boolean. Excel only. Indicates whether the filters info will be shown (true) in exported Excel file or not (false). Default value is false.
    • url – to save the file to the server you should provide the component with a path to the server-side script which can save this file.
    • useOlapFormattingInExcel (starting from v2.2) (optional) – Boolean. To configure how to export grid cells in Excel file if formatting is taken from OLAP cube – as a formatted string (true) or as numbers without formatting (false). Previously it was not configurable and the cells were exported as formatted strings.
  • callbackHandler (optional) – Callback handler is called with the following object: {data: result}.

Examples

Export to CSV, save as a local file and add a callback handler:

flexmonster.exportTo('csv', {filename : 'flexmonster.csv'}, 
    function(result) {console.log(result.data)}
);

Export to HTML and save as local file:

var params = {
  filename : 'flexmonster.html'
};
flexmonster.exportTo('html', params);

Export to PDF file, change page orientation to landscape and save file to the server:

var params = {
  filename : 'flexmonster.pdf', 
  pageOrientation : 'landscape',
  destinationType : 'server',
  url : 'your server'
};
flexmonster.exportTo('pdf', params);

Export to Excel and save as local file:

flexmonster.exportTo('excel');

See also

print