JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="exporter(1)">Export to HTML</button>
<button onclick="exporter(2)">Export to PDF</button>
<button onclick="exporter(3)">Export to CSV</button>
<div id="pivot-container"></div>

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 430,
  report: {
    dataSource: {
      data: getData()
    },

  }
});

function exporter(mode) {

  var options = {
    header: "<div style='border: 2px solid #df3800; background: #fff; color: #df3800; text-transform: uppercase; cursor: pointer; margin: 5px 0; display: inline-block; font-weight: normal; padding: 10px 10px; font-size: 14px;'>##CURRENT-DATE##</div>"
  }

  switch (mode) {

    case 1:
      flexmonster.exportTo('html', options);
      break;

    case 2:
      flexmonster.exportTo('pdf', options);
      break;

    case 3:
      flexmonster.exportTo("csv", {
        destinationType: "plain"
      }, function(res) {
        res.data = '"Custom title", "value"\n' + res.data;
        console.log(res);
        alert("The result is displayed within the console of your browser")
      });
      break;
  }

}

function getData() {
  return [{
    "Color": "green",
    "M": "September",
    "W": "Wed",
    "Country": "Canada",
    "State": "Ontario",
    "City": "Toronto",
    "Price": 174,
    "Quantity": 22
  }, {
    "Color": "red",
    "M": "March",
    "W": "Mon",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1664,
    "Quantity": 19
  }, {
    "Color": "red",
    "M": "January",
    "W": "Mon",
    "Country": "Canada",
    "State": "Quebec",
    "City": "Montreal",
    "Price": 1190,
    "Quantity": 292
  }, {
    "Color": "green",
    "D": "04/08/2014",
    "M": "August",
    "W": "Fri",
    "Time": "1000",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 1222,
    "Quantity": 730
  }, {
    "Color": "white",
    "M": "March",
    "W": "Wed",
    "Country": "USA",
    "State": "California",
    "City": "Los Angeles",
    "Price": 7941,
    "Quantity": 73
  }, {
    "Color": "red",
    "M": "August",
    "W":...