Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

ExportTo CSV Using Flexmonster.js

om asked on June 26, 2018

I want to use Flexmonster’s Export To CSV api without binding data to Pivot Control.Is it possible to use this api from other page just for exporting content to CSV.My page contains list of all reports, on clicking it, it should export content to CSV. Can I use Flexmonster.JS for this?

4 answers

Tanya Gryshko Tanya Gryshko Flexmonster June 27, 2018

Hello, Om,
Thank you for your interest in Flexmonster Pivot!
Export To CSV feature is applicable only to the content currently displayed on the grid. However, you can create Flexmonster instance without using a browser by means of PhantomJS. Please have a look at the following tutorial: How to export on the server without using a browser.
Let me know if you have any other questions.

om June 28, 2018

Thank you Tanya for the quick reply. But I have to use Flexmonster’s ExportAPI feature Without showing Pivot Grid.
In order to achieve this I believe, I need to bind data first to the PivotContainer and then use ExportAPI. Is this possible to achieve this by keeping PivotContainer Grid(div) hidden.

om June 28, 2018

Hi Tanya,
Here I am providing more details.
I added one button in HTML and Export functionality on click event and kept div of Pivot Container hidden.
Please find below HTML and Javascript code for the same.
It’s working but columns are not appearing in exported CSV file. How to make these columns visible in CSV file.Additionally I attached CSV file
<script src=””></script>
<div id=”pivot-container” style=”display: none;”></div>
<button onclick=”ExportCSV()”>Export CSV</button>
var pivot = new Flexmonster({
container: “#pivot-container”,
componentFolder: “”,
width: “100%”,
height: 430,
toolbar: true,
report: {
dataSource: {
filename: “data/sales.csv”,
slice: {
rows: [{
uniqueName: “Month”
}, {
uniqueName: “[Measures]”
columns: [{
uniqueName: “Category”,
levelName: “Product Name”,
filter: {
members: [
“category.[condiments].[bbq sauce]”,
“category.[breakfast cereals].[corn flakes]”,
“category.[bakery].[chocolate biscuits]”,
“category.[fruit preserves].[apple jam]”,
“category.[bakery].[apple cake]”,
“category.[soups].[tomato soup]”
measures: [{
“uniqueName”: “Revenue”,
“aggregation”: “sum”,
“format”: “2sfou03a”
conditions: [{
formula: “#value < 2500”,
measure: “Revenue”,
format: {
backgroundColor: “#df3800”,
color: “#FFFFFF”
isTotal: false
formula: “#value > 20000”,
measure: “Revenue”,
format: {
backgroundColor: “#00A45A”,
color: “#FFFFFF”
isTotal: false
formats: [{
name: “2sfou03a”,
thousandsSeparator: “,”,
decimalSeparator: “.”,
decimalPlaces: 2,
currencySymbol: “$”,
currencySymbolAlign: “left”,
nullValue: “”,
textAlign: “right”,
isPercent: false
ExportCSV = function()

pivot (24).csv

Tanya Gryshko Tanya Gryshko Flexmonster June 29, 2018

Hello, Om,
Thank you for your quick reply and specifying additional details.
For your scenario, the best option is to use PhantomJS. PhantomJS is a headless web browser scriptable with JavaScript. This means it allows using Flexmonster’s ExportAPI feature without showing Pivot Grid. With the help of the simple script, you can load an HTML page with Flexmonster instance, and export its content as CSV. Please note, that Pivot Grid is not visible in this case.
Here is PhantomJS homepage: Also, the link to a sample GitHub project with such export might be useful as well:
Please let me know whether you have managed to configure everything successfully.

Please login or Register to Submit Answer