We have updated Flexmonster Software License Agreement, effective as of September 30, 2025 (list of changes)
All documentation
Connecting to data source

Export the report

All current data from the grid or chart can be exported to various formats. By default, content is exported as a file to a user's device, but you can also export it to your server or customize how the exported content is handled.

Note that there are specifics of exporting reports. To see different examples of exporting the report, visit our Examples page.

In Flexmonster, you can also save, share, or print your report.

How to export the report

You can export the report via UI or using an API call:

Via Ui

Step 1. Open a view that you want to export. It can be one of the following:

  • Grid view: compact, classic (tabular), or flat.
  • Chart view: see available chart types.
  • Grid and charts view.
    This view can be opened by setting the viewType to "grid_charts" or by calling the showGridAndCharts method.
  • Drill-through view.

Note If you export a chart view to Excel or CSV, the grid view will be exported instead.

Step 2. Select Export ( ) on the Toolbar and choose the export format:

Export options available through the Export tab on the Toolbar

Using API call

To export the report programmatically, use the exportTo() API call. Its first parameter, type, defines the type of export. For example:

pivot.exportTo("pdf");

You can also configure different export parameters using the second exportTo() parameter, the params object, and specify a callbackHandler, a function that is called when the data is ready to be exported.

Export a report to the server

By default, the report contents are exported as a file to the local file system. To save the report to the server:

  1. Set params.destinationType to "server" in exportTo().
  2. Specify the server's URL in the params.url property.
  3. optional Add custom request headers.

Example:

pivot.exportTo("pdf", {
destinationType: "server",
url: "<url_to_your_server>",
requestHeaders: {
Authorization: "Basic " + btoa("<your_username>:<your_password>")
}
});

Export to the server without using a browser

To export Flexmonster reports in headless browsers, we recommend using Puppeteer. This approach provides more flexibility in exporting. For example, you can schedule automatic sending of the exported report to others (e.g., via email).

We prepared a sample GitHub project with Flexmonster and Puppeteer. There are two versions of the project: the main version uses Flexmonster from our CDN, while the other version includes Flexmonster from the npm package.

To run the sample project, follow the steps below:

Step 1. Download or clone the needed version of the sample project:

CDN version

Get the sample project where Flexmonster is included from CDN:

git clone https://github.com/flexmonster/pivot-puppeteer
cd pivot-puppeteer

npm package version

Get the sample project where Flexmonster is included from npm:

git clone -b flexmonster-from-nodemodules https://github.com/flexmonster/pivot-puppeteer
cd pivot-puppeteer

Step 2. Install the npm dependencies described in package.json:

npm install

Step 3. Run the project:

npm start

When the export is complete, find the saved files in the storage/ folder.

Now let's have a look at the project files' contents to understand how the sample project works:

index.html

The index.html file contains the pivot table subscribed to the ready, reportcomplete, and exportcomplete events. These events will notify us when the report is ready to be exported and when the export is finished.

When the component triggers one of these events, the dispatchEvent() method triggers the same event for the browser window. This approach allows the browser to handle the component's events in its scope.

You can specify other Flexmonster events similarly.

pivot.js

The pivot.js file runs the browser and performs the export. This section describes its key points.

In the sample project, we use ready, reportcomplete, and exportcomplete events to export the report. You can modify the event handlers to add new functionality, such as scheduled sending of the exported report via email. Other Flexmonster events can be added in a similar way — check it out.

The next important part of the project is where we set a report. It's done using the setReport() function as soon as the component is initialized. You can replace the default report with an inline report or a link to it.

The exportTo() function supports changing the file name or exporting the report to your server - just specify the corresponding export parameters. The structure of the parameters is the same as in the flexmonster.exportTo() API call.

For technical details on how the export is performed, see comments in the pivot.js file.

Define the name of the exported file

To specify the name of the resulting file, use the params.filename property. For example:

pivot.exportTo("pdf", {
filename: "flexmonster.pdf"
});

Live example

To specify a header and footer text in the exported file, use the params.header and params.footer properties respectively. Check out the specifics of setting headers and footers for different export types:

PDF

  • Both params.header and params.footer can be specified as a regular string or as an HTML string with tags, inline styles, and Base64 images. The HTML is rendered in the browser and added as an image to the exported file.
  • You can use the ##CURRENT-DATE## and ##PAGE-NUMBER## tokens in the string. They will be replaced with actual values during the export process.

Example:

pivot.exportTo("pdf", {
header: "##CURRENT-DATE##",
footer: "<div>##PAGE-NUMBER##</div>",
});

Live example

Excel

  • You can add a multirow header or footer using the "\n" character: "Row1\nRow2\nRow3".
  • A cell with the params.header or params.footer spans multiple columns in the exported Excel file, with a maximum of 10 columns. This ensures that the header is always visible to a user.
pivot.exportTo("excel", {
header: "First header row\nSecond header row",
footer: "Table Footer",
});

Live example

CSV

  • You can add a multirow header or footer using the "\n" character: "Row1\nRow2\nRow3".

Example:

pivot.exportTo("csv", {
header: "First header row\nSecond header row",
footer: "Table Footer",
});

Live example

HTML and Image

  • Both params.header and params.footer can be specified as a regular string or as an HTML string with tags, inline styles, and Base64 images. The HTML is rendered in the browser and added as an image to the exported file.
  • You can use the ##CURRENT-DATE## token in the string. It will be replaced with actual values during the export process.

Example:

pivot.exportTo("html", {
  header: "##CURRENT-DATE##",
  footer: "<div style='color:#df3800'>##PAGE-NUMBER##</div>",
});

Live example

More configs for PDF export

When exporting the report to PDF, you can additionally configure the following:

Check out the example of saving the report as a local PDF file:

const params = {
fontUrl: "https://cdn.flexmonster.com/fonts/NotoSansCJKtc-Regular.ttf",
pageFormat: "A3",
pageOrientation: "landscape"
};

pivot.exportTo("pdf", params);

Live example

CDN fonts for PDF export

Expand the list of Google Noto Fonts
LanguageURL
582 languageshttps://cdn.flexmonster.com/fonts/NotoSans-Regular.ttf
Adlamhttps://cdn.flexmonster.com/fonts/NotoSansAdlam-Regular.ttf
Adlam Unjoinedhttps://cdn.flexmonster.com/fonts/NotoSansAdlamUnjoined-Regular.ttf
Anatolian Hieroglyphshttps://cdn.flexmonster.com/fonts/NotoSansAnatolianHieroglyphs-Regular.ttf
Arabichttps://cdn.flexmonster.com/fonts/NotoSansArabic-Regular.ttf
Arabic UIhttps://cdn.flexmonster.com/fonts/NotoSansArabicUI-Regular.ttf
Armenianhttps://cdn.flexmonster.com/fonts/NotoSansArmenian-Regular.ttf
Avestanhttps://cdn.flexmonster.com/fonts/NotoSansAvestan-Regular.ttf
Balinesehttps://cdn.flexmonster.com/fonts/NotoSansBalinese-Regular.ttf
Bamumhttps://cdn.flexmonster.com/fonts/NotoSansBamum-Regular.ttf
Batakhttps://cdn.flexmonster.com/fonts/NotoSansBatak-Regular.ttf
Bengalihttps://cdn.flexmonster.com/fonts/NotoSansBengali-Regular.ttf
Bengali UIhttps://cdn.flexmonster.com/fonts/NotoSansBengaliUI-Regular.ttf
Brahmihttps://cdn.flexmonster.com/fonts/NotoSansBrahmi-Regular.ttf
Buginesehttps://cdn.flexmonster.com/fonts/NotoSansBuginese-Regular.ttf
Buhidhttps://cdn.flexmonster.com/fonts/NotoSansBuhid-Regular.ttf
Japanesehttps://cdn.flexmonster.com/fonts/NotoSansCJKjp-Regular.ttf
Koreanhttps://cdn.flexmonster.com/fonts/NotoSansCJKkr-Regular.ttf
Simplified Chinesehttps://cdn.flexmonster.com/fonts/NotoSansCJKsc-Regular.ttf
Traditional Chinesehttps://cdn.flexmonster.com/fonts/NotoSansCJKtc-Regular.ttf
Canadian Aboriginalhttps://cdn.flexmonster.com/fonts/NotoSansCanadianAboriginal-Regular.ttf
Carianhttps://cdn.flexmonster.com/fonts/NotoSansCarian-Regular.ttf
Chakmahttps://cdn.flexmonster.com/fonts/NotoSansChakma-Regular.ttf
Chamhttps://cdn.flexmonster.com/fonts/NotoSansCham-Regular.ttf
Cherokeehttps://cdn.flexmonster.com/fonts/NotoSansCherokee-Regular.ttf
Coptichttps://cdn.flexmonster.com/fonts/NotoSansCoptic-Regular.ttf
Cuneiformhttps://cdn.flexmonster.com/fonts/NotoSansCuneiform-Regular.ttf
Cypriothttps://cdn.flexmonster.com/fonts/NotoSansCypriot-Regular.ttf
Deserethttps://cdn.flexmonster.com/fonts/NotoSansDeseret-Regular.ttf
Devanagarihttps://cdn.flexmonster.com/fonts/NotoSansDevanagari-Regular.ttf
Devanagar iUIhttps://cdn.flexmonster.com/fonts/NotoSansDevanagariUI-Regular.ttf
Displayhttps://cdn.flexmonster.com/fonts/NotoSansDisplay-Regular.ttf
Egyptian Hieroglyphshttps://cdn.flexmonster.com/fonts/NotoSansEgyptianHieroglyphs-Regular.ttf
Ethiopichttps://cdn.flexmonster.com/fonts/NotoSansEthiopic-Regular.ttf
Georgianhttps://cdn.flexmonster.com/fonts/NotoSansGeorgian-Regular.ttf
Glagolitichttps://cdn.flexmonster.com/fonts/NotoSansGlagolitic-Regular.ttf
Gothichttps://cdn.flexmonster.com/fonts/NotoSansGothic-Regular.ttf
Gujaratihttps://cdn.flexmonster.com/fonts/NotoSansGujarati-Regular.ttf
Gujarati UIhttps://cdn.flexmonster.com/fonts/NotoSansGujaratiUI-Regular.ttf
Gurmukhihttps://cdn.flexmonster.com/fonts/NotoSansGurmukhi-Regular.ttf
Gurmukhi UIhttps://cdn.flexmonster.com/fonts/NotoSansGurmukhiUI-Regular.ttf
Hanunoohttps://cdn.flexmonster.com/fonts/NotoSansHanunoo-Regular.ttf
Hebrewhttps://cdn.flexmonster.com/fonts/NotoSansHebrew-Regular.ttf
Imperial Aramaichttps://cdn.flexmonster.com/fonts/NotoSansImperialAramaic-Regular.ttf
Inscriptional Pahlavihttps://cdn.flexmonster.com/fonts/NotoSansInscriptionalPahlavi-Regular.ttf
Inscriptional Parthianhttps://cdn.flexmonster.com/fonts/NotoSansInscriptionalParthian-Regular.ttf
Javanesehttps://cdn.flexmonster.com/fonts/NotoSansJavanese-Regular.ttf
Kaithihttps://cdn.flexmonster.com/fonts/NotoSansKaithi-Regular.ttf
Kannadahttps://cdn.flexmonster.com/fonts/NotoSansKannada-Regular.ttf
Kannada UIhttps://cdn.flexmonster.com/fonts/NotoSansKannadaUI-Regular.ttf
Kayah Lihttps://cdn.flexmonster.com/fonts/NotoSansKayahLi-Regular.ttf
Kharoshthihttps://cdn.flexmonster.com/fonts/NotoSansKharoshthi-Regular.ttf
Khmerhttps://cdn.flexmonster.com/fonts/NotoSansKhmer-Regular.ttf
Khmer UIhttps://cdn.flexmonster.com/fonts/NotoSansKhmerUI-Regular.ttf
Laohttps://cdn.flexmonster.com/fonts/NotoSansLao-Regular.ttf
Lao UIhttps://cdn.flexmonster.com/fonts/NotoSansLaoUI-Regular.ttf
Lepchahttps://cdn.flexmonster.com/fonts/NotoSansLepcha-Regular.ttf
Limbuhttps://cdn.flexmonster.com/fonts/NotoSansLimbu-Regular.ttf
Linear Bhttps://cdn.flexmonster.com/fonts/NotoSansLinearB-Regular.ttf
Lisuhttps://cdn.flexmonster.com/fonts/NotoSansLisu-Regular.ttf
Lycianhttps://cdn.flexmonster.com/fonts/NotoSansLycian-Regular.ttf
Lydianhttps://cdn.flexmonster.com/fonts/NotoSansLydian-Regular.ttf
Malayalamhttps://cdn.flexmonster.com/fonts/NotoSansMalayalam-Regular.ttf
Malayalam UIhttps://cdn.flexmonster.com/fonts/NotoSansMalayalamUI-Regular.ttf
Mandaichttps://cdn.flexmonster.com/fonts/NotoSansMandaic-Regular.ttf
Meetei Mayekhttps://cdn.flexmonster.com/fonts/NotoSansMeeteiMayek-Regular.ttf
Mongolianhttps://cdn.flexmonster.com/fonts/NotoSansMongolian-Regular.ttf
Myanmarhttps://cdn.flexmonster.com/fonts/NotoSansMyanmar-Regular.ttf
Myanmar UIhttps://cdn.flexmonster.com/fonts/NotoSansMyanmarUI-Regular.ttf
N'Kohttps://cdn.flexmonster.com/fonts/NotoSansNKo-Regular.ttf
New Tai Luehttps://cdn.flexmonster.com/fonts/NotoSansNewTaiLue-Regular.ttf
Oghamhttps://cdn.flexmonster.com/fonts/NotoSansOgham-Regular.ttf
Ol Chikihttps://cdn.flexmonster.com/fonts/NotoSansOlChiki-Regular.ttf
Old Italichttps://cdn.flexmonster.com/fonts/NotoSansOldItalic-Regular.ttf
Old Persianhttps://cdn.flexmonster.com/fonts/NotoSansOldPersian-Regular.ttf
Old South Arabianhttps://cdn.flexmonster.com/fonts/NotoSansOldSouthArabian-Regular.ttf
Old Turkichttps://cdn.flexmonster.com/fonts/NotoSansOldTurkic-Regular.ttf
Oriyahttps://cdn.flexmonster.com/fonts/NotoSansOriya-Regular.ttf
Oriya UIhttps://cdn.flexmonster.com/fonts/NotoSansOriyaUI-Regular.ttf
Osagehttps://cdn.flexmonster.com/fonts/NotoSansOsage-Regular.ttf
Osmanyahttps://cdn.flexmonster.com/fonts/NotoSansOsmanya-Regular.ttf
Phags-pahttps://cdn.flexmonster.com/fonts/NotoSansPhagsPa-Regular.ttf
Phoenicianhttps://cdn.flexmonster.com/fonts/NotoSansPhoenician-Regular.ttf
Rejanghttps://cdn.flexmonster.com/fonts/NotoSansRejang-Regular.ttf
Runichttps://cdn.flexmonster.com/fonts/NotoSansRunic-Regular.ttf
Samaritanhttps://cdn.flexmonster.com/fonts/NotoSansSamaritan-Regular.ttf
Saurashtrahttps://cdn.flexmonster.com/fonts/NotoSansSaurashtra-Regular.ttf
Shavianhttps://cdn.flexmonster.com/fonts/NotoSansShavian-Regular.ttf
Sinhalahttps://cdn.flexmonster.com/fonts/NotoSansSinhala-Regular.ttf
Sinhala UIhttps://cdn.flexmonster.com/fonts/NotoSansSinhalaUI-Regular.ttf
Sundanesehttps://cdn.flexmonster.com/fonts/NotoSansSundanese-Regular.ttf
Syloti Nagrihttps://cdn.flexmonster.com/fonts/NotoSansSylotiNagri-Regular.ttf
Symbolshttps://cdn.flexmonster.com/fonts/NotoSansSymbols-Regular.ttf
Symbols2https://cdn.flexmonster.com/fonts/NotoSansSymbols2-Regular.ttf
Syriac Easternhttps://cdn.flexmonster.com/fonts/NotoSansSyriacEastern-Regular.ttf
Syriac Estrangelahttps://cdn.flexmonster.com/fonts/NotoSansSyriacEstrangela-Regular.ttf
Syriac Westernhttps://cdn.flexmonster.com/fonts/NotoSansSyriacWestern-Regular.ttf
Tagaloghttps://cdn.flexmonster.com/fonts/NotoSansTagalog-Regular.ttf
Tagbanwahttps://cdn.flexmonster.com/fonts/NotoSansTagbanwa-Regular.ttf
Tai Lehttps://cdn.flexmonster.com/fonts/NotoSansTaiLe-Regular.ttf
Tai Thamhttps://cdn.flexmonster.com/fonts/NotoSansTaiTham-Regular.ttf
Tai Viethttps://cdn.flexmonster.com/fonts/NotoSansTaiViet-Regular.ttf
Tamilhttps://cdn.flexmonster.com/fonts/NotoSansTamil-Regular.ttf
Tamil UIhttps://cdn.flexmonster.com/fonts/NotoSansTamilUI-Regular.ttf
Teluguhttps://cdn.flexmonster.com/fonts/NotoSansTelugu-Regular.ttf
Telugu UIhttps://cdn.flexmonster.com/fonts/NotoSansTeluguUI-Regular.ttf
Thaanahttps://cdn.flexmonster.com/fonts/NotoSansThaana-Regular.ttf
Thaihttps://cdn.flexmonster.com/fonts/NotoSansThai-Regular.ttf
Thai UIhttps://cdn.flexmonster.com/fonts/NotoSansThaiUI-Regular.ttf
Tibetanhttps://cdn.flexmonster.com/fonts/NotoSansTibetan-Regular.ttf
Tifinaghhttps://cdn.flexmonster.com/fonts/NotoSansTifinagh-Regular.ttf
Ugaritichttps://cdn.flexmonster.com/fonts/NotoSansUgaritic-Regular.ttf
Vaihttps://cdn.flexmonster.com/fonts/NotoSansVai-Regular.ttf
Yihttps://cdn.flexmonster.com/fonts/NotoSansYi-Regular.ttf

More configs for Excel export

When exporting the report to Excel, you can additionally configure the following:

Check out the example:

const params = {
excelSheetName: "Report",
showFilters: true,
useOlapFormattingInExcel: false
};

pivot.exportTo("excel", params);

Live example

Change the separators for thousands and decimals in the exported file

In the exported Excel file, separators for thousands and decimals are taken from your system's regional settings instead of the thousandsSeparator and the decimalSeparator set in the component.

See how to change the separator for thousands and decimals in Excel.

Display measures as integers in the exported file

When exporting the report to Excel, measures will contain at least one decimal place in the output file if they don't have a number format with the explicitly defined decimalPlaces property.

To display the necessary measures as integers, set the decimalPlaces to 0 in the number format for these measures:

report: {
formats: [
{
name: "decimalFormat",
decimalPlaces: 0
}
],
slice: {
measures: [
{
uniqueName: "Price",
aggregation: "sum",
format: "decimalFormat"
},
],
// Other slice properties
},
// Other configs
}

Live example

Alternatively, all measures can be displayed as integers in the output file if you set the decimalPlaces to 0 in the default number format.

  • If you export a chart view to Excel, the grid view will be exported instead.
  • "date string", "datetime", and "time" fields selected for measures will use the default Excel format in the exported file instead of the datePattern, dateTimePattern, and timePattern formats. See how to create a custom date or time format in Excel.
  • Bold formatting for value cells is not included in the exported Excel file.
  • Some styles from Flexmonster themes or сustom CSS are not included in the exported Excel file.

Other specifics of exporting to Excel

When you export the report to Excel, consider the following specifics:

  • Some styles from Flexmonster themes or сustom CSS are not included in the exported Excel file.
  • If you export a chart view to Excel, the grid view will be exported instead.
  • "date string", "datetime", and "time" fields selected for measures will use the default Excel format in the exported file instead of the datePattern, dateTimePattern, and timePattern formats. See how to create a custom date or time format in Excel.
  • Bold formatting for value cells is not included in the exported Excel file.
  • Some styles from Flexmonster themes or сustom CSS are not included in the exported Excel file.

More configs for CSV export

When exporting the report to CSV, you can additionally configure the following:

Note If you export a chart view to CSV, the grid view will be exported instead.

See an example:

const params = {
alwaysEnclose: true,
fieldSeparator: ";",
};

pivot.exportTo("csv", params);

Live example

Advanced export

To customize how exported data is handled, set params.destinationType to "plain". As a result, the exported content is passed to the callbackHandler and can be modified, merged, or saved in any format you need.

For example, if you have multiple Flexmonster instances, you may want to export data from them into one file. Check out how to merge export results for a CSV export:

function doubleExportCsv() {

// Export report from the 1st Flexmonster instance
pivot1.exportTo(
"csv",{
destinationType: "plain"
},
csv1 => {

// Export report from the 2nd Flexmonster instance
pivot2.exportTo(
"csv", {
destinationType: "plain"
},
csv2 => {

// Concat data from two reports into one
const mergedCsv = csv1.data + "\n\n" + csv2.data;

// Download the CSV file with two reports using the downloadjs library
download(mergedCsv, "doubleInstances.csv", "text/csv")
},
);
},
);
}

Live example

Override the Export tab functionality

In Flexmonster, you can modify or override the functionality of the Export tab. For more details, see how to customize the tab functionality.

Specifics of exporting reports

When you export the report, consider that the resulting file is static and contains the data that is present on the grid and charts at the moment of exporting. This means the following:

  • A node is not included in the exported file if its parent nodes are collapsed.
  • A hierarchy level is not included in the exported file if its parent hierarchy levels are drilled up.
  • In the exported file, expanded nodes cannot be collapsed and drilled-down levels cannot be drilled up.
  • Fields that are not included in the slice are not included in the exported file as well.

Also, note that the chart view or the grid and charts view can be exported only to PDF, HTML, or an image. If you start exporting a chart view to Excel or CSV, the grid view will be exported instead.

To ensure the best performance when exporting the report, do not switch to other browser tabs, and do not minimize the browser window.

How to display non-Latin characters in the exported file

If you are using data or localization with non-Latin characters, ensure you have set UTF-8 encoding for your data or page. This is required to display the exported report file correctly in the component.

Note To correctly export the report with non-Latin characters to PDF, use the exportTo() method with the params.fontUrl property set to the URL that leads to the necessary TTF font file.

How cells modified by customizeCell are displayed in the exported file

By default, if you modify a value cell using the cell.text property, this cell will be exported as a string. If you want such cells to be exported as unformatted numbers, set the useCustomizeCellForData to false.

Note If the cell.text property contains custom HTML code, the useCustomizeCellForData must be set to false. Otherwise, raw HTML code will be displayed in the exported file.

See also