JSFiddle - React, Tailwind, and code Playground

Export and print

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="excel()">Export to excel</button>

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  report: {
    customFields: [
      {
        name: "Field1",
        value: "Value1",
      },
      {
        name: "Field2",
        value: "Value2",
      },
    ],
    dataSource: {
      filename: "data/data.csv",
    },
  },
});

function excel() {
  pivot.exportTo(
    "excel",
    {
      destinationType: "plain",
    },
    (result) => {
      const data = result.data;
      console.log(data);
    },
  );
}