Documentation menu

exportTo

exportTo(exportType:String, parameters:Object, callback:Function|String)

Exports the content from the grid to Excel, PDF or HTML. Such an export file can be saved both locally and to a server.

Parameters

NameTypeDescription
exportTypeStringOne of the following export types: "excel", "pdf" or "html".
parametersObjectoptional Describes export parameters. Can have the following properties:
  • filename
Stringoptional The name of the export file. The default name is pivot.
  • destinationType
Stringoptional Destination for the download. By default, destinationType is set to "file", which means the export file is saved locally. Set destinationType as "server" to save the export file to the server.
  • url
Stringoptional The URL to the server script saving the export file. It is required when saving the export file to the server (the export file is passed as a POST parameter).
  • excelSheetName
Stringoptional Property to set custom sheet name when exporting to Excel.
  • showFilters
Booleanoptional If true, shows the filters in exported Excel file.
  • header
Stringoptional Only for PDF and HTML export. HTML string added to the export file as a header.
For example, "<div>##CURRENT-DATE##</div>".
  • footer
Stringoptional Only for PDF and HTML export. HTML string added to the export file as a footer.
For example, "<div>##CURRENT-DATE##</div>".
  • pageOrientation
Stringoptional Page orientation for PDF file. By default, pageOrientation is set to "portrait", which means the export file is saved in portrait mode. Set pageOrientation as "landscape" to save the export file in landscape mode.
callbackFunction | Stringoptional Callback handler, which is called after the export process is finished.

Examples

1) Export content to Excel or PDF:

2) Export content to PDF with a custom header, save it to a server and add a callback:

webdatarocks.exportTo(
	"pdf",
	{
		header:"<div>##CURRENT-DATE##</div>",
		destinationType: "server",
		url: "URL to server script saving the file"
	},
	function () {
		console.log("Export process is finished");
	}
);