Flexmonster Software License Agreement (“Agreement”) has been significantly revised and is effective as of September 30, 2024.
The following modifications were made:
The modified version of Flexmonster Software License Agreement is available here.
Downloading, installing, and/or continuing to use Flexmonster Software after September 30, 2024, constitutes Licensee’s acceptance of the terms and conditions of the modified version of Flexmonster Software License Agreement. If Licensee does not agree to any of these terms and conditions, they must cease using Flexmonster Software and must not download, install, use, access, or continue to access Flexmonster Software. By continuing to use Flexmonster Software or renewing the license under License Model or Maintenance after the effective date of any modifications to Agreement, Licensee accepts and agrees to be bound by the terms and conditions of the modified Agreement.
exportTo(type: String, params: ParamsObject, callbackHandler: Function)
[starting from version: 1.4]
Exports the current view to Excel, PDF, CSV, HTML, or image 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).
To learn more about export, see this guide: Export the report.
Parameter/Type | Description |
---|---|
type String | A type of export. The following types are available: "excel" , "pdf" , "csv" , "html" , "image" . |
params ParamsObject | optional Contains export parameters. |
callbackHandler Function | optional A JS function that is called when the data is ready to be exported. The following data is passed to the callbackHandler :
|
Property/Type | Description |
---|---|
alwaysEnclose Boolean | optional Indicates whether to enclose all CSV fields in quotes. When set to true , the fields are always enclosed in quotes. Otherwise, they will be enclosed only when necessary (e.g., if a field contains a comma: Bike, "$15,000", blue ). Only for CSV export. Default value: false . |
filename String | optional A default name of the resulting file. |
destinationType String | optional It defines where the component's contents will be exported. The destinationType can have the following values:
"file" . |
excelSheetName String | optional To configure the sheet name when exporting to an Excel file. |
fieldSeparator String | optional Defines specific fields separator to split CSV row in the export file. Only for CSV export. Default value: , . |
fontUrl String | optional The URL to the TTF font file for saving PDF reports in Chinese, Arabic, or any other language. Check out the list of ready-to-use Google Noto Fonts that you can use to support almost any language in the world. Only fonts in standard TTF format are supported. Live example |
header String | HTML String | optional String that will be displayed in the header section of the exported file. The header 's type and how it works depend on the export type:
|
footer String | HTML String | optional String that will be displayed in the footer section of the exported file. The footer 's type and how it works depend on the export type:
|
pageFormat String | optional It defines the page format for a PDF file. There are such types available: "A0" , "A1" , "A2" , "A3" , "A4" , "A5" .Default value: "A4" . |
pageOrientation String | optional It defines the page orientation for a PDF file. Page orientation can be the following:
|
requestHeaders Object | optional It allows adding custom request headers when the destinationType property is "server" . The object consists of "key": "value" pairs, where "key" is a header name and "value" is its value. |
showFilters Boolean | optional Indicates whether the exported file should list all filtered fields (true ) or filtered fields only from report filters (false ).If there are no fields in report filters, this property is ignored. Only for Excel export. Default value: false . |
url String | optional A path to a server-side script that can save the file. The url property is required when the destinationType property is "server" . |
useOlapFormattingInExcel Boolean | optional To configure how to export grid cells in an Excel file if formatting is taken from OLAP cube – as a formatted string (true ) or as numbers without formatting (false ).Only for Excel export. |
useCustomizeCellForData Boolean | optional Indicates whether cells modified by customizeCell() are exported as formatted strings (true ) or as numbers without formatting (false ). Learn more about how the modified cells are displayed in the exported file.Not available for the "image" export type.Default value: true . |
Property/Type | Description |
---|---|
data String | Uint8Array | The data to be exported. The data ’s type depends on the type of the export:
"plain" — learn more here. |
filename String | The name of the resulting file. |
response String | optional The server’s response. This property is defined only when the destinationType is set to "server" . |
type String | The export type specified in the type parameter. |
Property/Type | Description |
---|---|
message String | The error message. |
response String | optional The server’s response. This property is defined only when the destinationType is set to "server" . |
status Number | optional The response status code. This property is defined only when the destinationType is set to "server" . |
1) This example on JSFiddle demonstrates all types of export: CSV, HTML, PDF, Image and Excel.
2) Export to PDF, modify generated file and save locally:
pivot.exportTo("pdf", { destinationType: "plain" }, function(res) {
let pdf = res.data;
pdf.addPage();
pdf.text('Hello world!', 10, 10);
pdf.save(res.filename);
});
3) Export to CSV, save as a local file and add a callback handler:
pivot.exportTo('csv', {filename : 'flexmonster.csv'},
function(result) { console.log(result.data); }
);
4) Export to HTML and save as local file:
const params = {
filename : 'flexmonster.html'
};
pivot.exportTo('html', params);
5) Export to PDF file, change page orientation to landscape and save file to the server:
const params = {
filename : 'flexmonster.pdf',
pageOrientation : 'landscape',
destinationType : 'server',
url : 'your server'
};
pivot.exportTo('pdf', params);
6) Export to Excel and save as local file:
pivot.exportTo('excel');
7) Export to PDF and set TTF font file:
pivot.exportTo('pdf', {
fontUrl: 'https://cdn.flexmonster.com/fonts/NotoSansCJKtc-Regular.ttf'
});
8) Export reports from multiple Flexmonster instances into one file.
Each report is exported separately and then merged with others into one file. The exact approach is different depending on the export type Live example.