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="csv()">Export to CSV</button>
<div id="pivot-container"></div>

JavaScript

function csv() {
  var params = {
    filename: 'flexmonster',
    showFilters: true
  };
  flexmonster.exportTo('csv', params);
}

var currentLang = 'ch';

function setLocalization(lang) {
  currentLang = lang;
  pivot.setReport({
    dataSource: {
      type: "csv",
      filename: "data/data-" + lang + ".csv"
    },
    localization: "loc/" + lang + ".json"
  });
}

var pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  global: {
    localization: "loc/ch.json"
  },
  report: {
    dataSource: {
      type: "csv",
      filename: "data/data-ch.csv"
    },
    options: {
      configuratorActive: false
    }
  },
  width: "100%",
  height: 430,
  toolbar: true,
  beforetoolbarcreated: customizeToolbar
});

var pdfFonts = {
  "zh": "https://cdn.flexmonster.com/fonts/NotoSansCJKsc-Regular.ttf"
}

function customizeToolbar(toolbar) {
  FlexmonsterToolbar.prototype.exportHandler = function(type) {
    if (type == "pdf") {
      this.pivot.exportTo(type, {
        fontUrl: pdfFonts[currentLang]
      });
    } else {
      this.pivot.exportTo(type);
    }
  }
  var tabs = toolbar.getTabs();
  toolbar.getTabs = function() {
    var singleTab = [tabs[3]];
    return singleTab;
  }
}