@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 4.59 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@lxlib/util"),require("file-saver"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/seed/xlsx",["exports","@angular/core","@angular/common/http","@lxlib/util","file-saver","@angular/common"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed.xlsx={}),e.ng.core,e.ng.common.http,e.lxlib.util,e.saveAs,e.ng.common)}(this,(function(e,t,r,o,n,i){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var a=function(){return(a=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return a}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e}var c=function(){function e(){this.url="//cdn.bootcss.com/xlsx/0.12.13/xlsx.full.min.js",this.modules=[]}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var u=function(){function e(e,t,r){this.cog=e,this.http=t,this.lazy=r}return e.prototype.init=function(){return"undefined"!=typeof XLSX?Promise.resolve([]):this.lazy.load([this.cog.url].concat(this.cog.modules))},e.prototype.read=function(e){var t={};return e.SheetNames.forEach((function(r){var o=e.Sheets[r];t[r]=XLSX.utils.sheet_to_json(o,{header:1})})),t},e.prototype.import=function(e,t){var r=this;return void 0===t&&(t="readAsBinaryString"),new Promise((function(o,n){r.init().then((function(){if("string"!=typeof e){var i=new FileReader;i.onload=function(e){var t=XLSX.read(e.target.result,{type:"binary"});o(r.read(t))},i[t](e)}else r.http.request("GET",e,{responseType:"arraybuffer"}).subscribe((function(e){var t=XLSX.read(new Uint8Array(e),{type:"array"});o(r.read(t))}),(function(e){n(e)}))})).catch((function(){return n("Unable to load xlsx.js")}))}))},e.prototype.export=function(e){return this.init().then((function(){var t=XLSX.utils.book_new();Array.isArray(e.sheets)?e.sheets.forEach((function(e,r){var o=XLSX.utils.aoa_to_sheet(e.data);XLSX.utils.book_append_sheet(t,o,e.name||"Sheet"+(r+1))})):(t.SheetNames=Object.keys(e.sheets),t.Sheets=e.sheets),e.callback&&e.callback(t);var r=XLSX.write(t,a({bookType:"xlsx",bookSST:!1,type:"array"},e.opts));n.saveAs(new Blob([r],{type:"application/octet-stream"}),e.filename||"export.xlsx")}))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:c},{type:r.HttpClient},{type:o.LazyService}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(c),t.ɵɵinject(r.HttpClient),t.ɵɵinject(o.LazyService))},token:e,providedIn:"root"}),e}();var p=function(){function e(e){this.srv=e}return e.prototype._click=function(){this.srv.export(this.data)},e.decorators=[{type:t.Directive,args:[{selector:"[xlsx]",exportAs:"xlsx",host:{"(click)":"_click()"}}]}],e.ctorParameters=function(){return[{type:u}]},e.propDecorators={data:[{type:t.Input,args:["xlsx"]}]},e}();var f=[p],d=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[i.CommonModule,o.LxlibUtilModule],declarations:l(f),exports:l(f)}]}],e}();e.XlsxConfig=c,e.XlsxDirective=p,e.XlsxModule=d,e.XlsxService=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=xlsx.umd.min.js.map