import _Button from "antd/es/button";
/*
 * @Author: wangrongrong wangrongrong@bigo.sg
 * @Date: 2022-06-23 15:42:02
 * @LastEditors: wangrongrong wangrongrong@bigo.sg
 * @LastEditTime: 2023-03-15 11:35:46
 * @FilePath: /lowcode-material/devopsComponent/src/components/export-xlsx-component/export-xlsx-component.tsx
 * @Description: excel用户自定义数据文件下载组件
 */
import "./index.css";
import ExportJsonExcel from 'js-export-excel';
export default function ExportXlsxComponent(props) {
  var source = props.source,
    title = props.title,
    header = props.header;
  var downloadExcel = function downloadExcel() {
    var option = {
      fileName: ''
    };
    var item;
    if (Array.isArray(source)) {
      item = source[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 ExportJsonExcel(option);
    toExcel.saveExcel();
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "Editor"
  }, /*#__PURE__*/React.createElement(_Button, {
    onClick: downloadExcel
  }, "\u5BFC\u51FAExcel"));
}