@progress/kendo-react-excel-export
Version:
React Excel export helps you export and save data to Excel files and customize or filter the output. KendoReact Excel Export package
9 lines (8 loc) • 3.19 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),e=require("prop-types"),y=require("@progress/kendo-file-saver"),p=require("./ooxml/workbook.js"),c=require("@progress/kendo-react-common"),m=require("./package-metadata.js");function g(a){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return o.default=a,Object.freeze(o)}const i=g(u),n=class n extends i.Component{constructor(o){super(o),this.showLicenseWatermark=!1,this.saveFile=t=>{y.saveAs(t,this.props.fileName,{forceProxy:this.props.forceProxy,proxyURL:this.props.proxyURL})},this.extractColumns=(t,r=0)=>Array.isArray(t)?t.map(s=>this.extractChild(s,r)):[t,this.extractChild(t,r)],this.extractChild=(t,r=0)=>i.isValidElement(t)?{...t.props,width:t.props.width&&parseInt(`${t.props.width}`,10),level:r,children:t.props.children&&this.extractColumns(t.props.children,r+1)}:{...t,level:r,children:t.children&&this.extractColumns(t.children,r+1)},this.getExportData=t=>{let r;return t?Array.isArray(t)?r={data:t}:r=t:r={data:this.props.data,group:this.props.group},r},this.showLicenseWatermark=!c.validatePackage(m.packageMetadata,{component:"ExcelExport"}),this.save=this.save.bind(this),this.toDataURL=this.toDataURL.bind(this),this.workbookOptions=this.workbookOptions.bind(this)}save(o,t){this.toDataURL(o,t).then((...r)=>{this.props.onExportComplete&&this.props.onExportComplete.call(void 0,{target:this}),this.saveFile(...r)})}toDataURL(o,t){const r=p.isWorkbookOptions(o)?o:this.workbookOptions(o,t);return p.toDataURL(r)}workbookOptions(o,t){const r=this.getExportData(o),s=this.props.children,h=s&&s.type&&s.type.displayName==="KendoReactGrid"&&s.props&&i.Children.toArray(s.props.children),d=this.extractColumns(h||t||this.props.columns||i.Children.toArray(s));return p.workbookOptions({columns:d,data:r.data,group:r.group,filterable:this.props.filterable,creator:this.props.creator,date:this.props.date,dir:this.props.dir,hierarchy:this.props.hierarchy,paddingCellOptions:this.props.paddingCellOptions,headerPaddingCellOptions:this.props.headerPaddingCellOptions,collapsible:this.props.collapsible})}render(){return i.createElement(i.Fragment,null,this.props.children||null,this.showLicenseWatermark&&i.createElement(c.WatermarkOverlay,null))}};n.propTypes={children:e.any,columns:e.arrayOf(e.any),creator:e.string,data:e.any,date:e.any,filterable:e.bool,fileName:e.string,forceProxy:e.bool,group:e.any,headerPaddingCellOptions:e.any,paddingCellOptions:e.any,proxyURL:e.string,dir:e.string,hierarchy:e.bool,collapsible:e.bool},n.defaultProps={fileName:"Export.xlsx",forceProxy:!1,collapsible:!1};let l=n;exports.ExcelExport=l;