"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = ExportXlsxComponent;
var _button = _interopRequireDefault(require("antd/lib/button"));
require("./index.css");
var _jsExportExcel = _interopRequireDefault(require("js-export-excel"));
function ExportXlsxComponent(props) {
  var source = props.source,
    title = props.title,
    header = props.header;
  var downloadExcel = function downloadExcel() {
    var option = {};
    var item;
    if (Array.isArray(source)) {
      item = source[0];
    }
    // item = Array.isArray(datas) && datas[0];
    var keys = Object.keys(item);
    var values = Object.values(item);
    option.fileName = title;
    option.datas = [{
      sheetData: source,
      sheetName: 'sheet',
      sheetFilter: keys,
      sheetHeader: header || keys
    }];
    var toExcel = new _jsExportExcel["default"](option);
    toExcel.saveExcel();
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "Editor"
  }, /*#__PURE__*/React.createElement(_button["default"], {
    onClick: downloadExcel
  }, "\u5BFC\u51FAExcel"));
}