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="exportToExcel()">Export to Excel</button>

<div id="pivot-container"></div>

CSS

h2 {
  text-align: center;
}

p {
  font-size: 15px;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;
}

a {
  color: #00a45a;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
    font-size: 105%;
    color: #DF3800;
    background-color: #f5f5f5;
    padding: 1px 4px;
    font-family: monospace !important;
    border-radius: 4px;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  customizeCell: customizeCellFunction,
  report: {
    dataSource: {
      filename: "data/retail-data.json",
      mapping: {
        "Order Date": {
          type: "year/quarter/month/day"
        },
      }
    },
    slice: {
      rows: [{
          uniqueName: "Country",
          filter: {
            members: [
              "country.[australia]",
              "country.[usa]",
              "country.[japan]"
            ]
          }
        },
        {
          uniqueName: "Status",
        }
      ],
      columns: [{
          uniqueName: "Order Date"
        },
        {
          uniqueName: "[Measures]"
        }
      ],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum",
      }],
      expands: {
        rows: [{
          tuple: [
            "country.[japan]"
          ]
        }]
      },
      drills: {
        columns: [{
          tuple: [
            "order date.[2019]"
          ]
        }]
      },
    },
    options: {
      grid: {
        type: "classic",
        showTotals: "off"
      }
    }
  }
});

function customizeCellFunction(cell, data) {
  if (data && data.type == "header" &&
    data.member &&
    data.member.caption != 'All' &&
    data.label == "") {
    cell.text = "&nbsp;&nbsp;&nbsp;&nbsp;" + data.member.caption;
  }
}

function exportToExcel(){
pivot.exportTo("excel");
}