update
This commit is contained in:
8
dist/index.common.js
vendored
8
dist/index.common.js
vendored
File diff suppressed because one or more lines are too long
6
dist/index.js
vendored
6
dist/index.js
vendored
@@ -119,7 +119,7 @@
|
||||
|
||||
var sheet = _xlsx["default"].utils.json_to_sheet((isHeader ? [colHead] : []).concat(rowList).concat(footList), {
|
||||
skipHeader: true
|
||||
}); // 列宽
|
||||
}); // 设置列宽
|
||||
|
||||
|
||||
sheet['!cols'] = sheetCols; // 转换数据
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
var blob = new Blob([toBuffer(wbout)], {
|
||||
type: 'application/octet-stream'
|
||||
}); // 保存导出
|
||||
}); // 导出 xlsx
|
||||
|
||||
downloadFile(blob, options);
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
duration: -1
|
||||
});
|
||||
|
||||
setTimeout(exportMethod, 1000);
|
||||
setTimeout(exportMethod, 1500);
|
||||
} else {
|
||||
exportMethod();
|
||||
}
|
||||
|
||||
2
dist/index.min.js
vendored
2
dist/index.min.js
vendored
@@ -1 +1 @@
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define("vxe-table-plugin-export-xlsx",["exports","xe-utils","xlsx"],t);else if("undefined"!=typeof exports)t(exports,require("xe-utils"),require("xlsx"));else{var n={exports:{}};t(n.exports,e.XEUtils,e.XLSX),e.VXETablePluginExportXLSX=n.exports.default}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,g,h){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}var y;function n(e){var o="xlsx",a=e.$table,r=e.options,i=e.columns,t=e.datas,s=r.sheetName,l=r.isHeader,n=r.isFooter,u=r.original,f=r.footerFilterMethod,c=!1!==r.message,d={},p=[],m=[];l&&i.forEach(function(e){d[e.id]=u?e.property:e.getTitle(),m.push({wpx:g.default.toInteger(.8*e.renderWidth)})});var x=t.map(function(t){return i.forEach(function(e){t[e.id]=function(e,t){if(t)switch(e.cellType){case"string":break;case"number":if(!isNaN(t))return Number(t);break;default:if(t.length<12&&!isNaN(t))return Number(t)}return t}(e,t[e.id])}),t});if(n){var v=a.getTableData().footerData;(f?v.filter(f):v).forEach(function(n){var o={};i.forEach(function(e){var t;o[e.id]=(t=e,n[a.$getColumnIndex(t)])}),p.push(o)})}function b(){var e=h.default.utils.book_new(),t=h.default.utils.json_to_sheet((l?[d]:[]).concat(x).concat(p),{skipHeader:!0});t["!cols"]=m,h.default.utils.book_append_sheet(e,t,s);var n=h.default.write(e,{bookType:"xlsx",bookSST:!1,type:"binary"});!function(e,t){if(window.Blob){var n=t.filename,o=t.type;if(navigator.msSaveBlob)navigator.msSaveBlob(e,"".concat(n,".").concat(o));else{var a=document.createElement("a");a.target="_blank",a.download="".concat(n,".").concat(o),a.href=URL.createObjectURL(e),document.body.appendChild(a),a.click(),document.body.removeChild(a)}}else console.error(y.t("vxe.error.notExp"))}(new Blob([function(e){for(var t=new ArrayBuffer(e.length),n=new Uint8Array(t),o=0;o!==e.length;++o)n[o]=255&e.charCodeAt(o);return t}(n)],{type:"application/octet-stream"}),r),c&&(y.modal.close(o),y.modal.message({message:y.t("vxe.table.expSuccess"),status:"success"}))}c?(y.modal.message({id:o,message:y.t("vxe.table.expLoading"),status:"loading",duration:-1}),setTimeout(b,1e3)):b()}function p(e){return e.replace(/^"/,"").replace(/"$/,"")}function o(e){var l=e.columns,u=e.options,t=e.file,f=!1!==u.message,c=e.$table,d=c._importResolve,n=new FileReader;n.onload=function(e){var t,n,o=h.default.read(e.target.result,{type:"binary"}),a=function(e){var t=e.split("\n"),o=[],a=[];if(t.length){var n=t.slice(1);t[0].split(",").map(p),n.forEach(function(e){if(e){var n={};e.split(",").forEach(function(e,t){o[t]&&(n[o[t]]=p(e))}),a.push(n)}})}return{fields:o,rows:a}}(h.default.utils.sheet_to_csv(o.Sheets.Sheet1)),r=a.fields,i=a.rows,s=(t=r,n=[],l.forEach(function(e){var t=e.property;t&&n.push(t)}),n.every(function(e){return t.includes(e)}));s?(c.createData(i).then(function(e){"append"===u.mode?c.insertAt(e,-1):c.reloadData(e)}),f&&y.modal.message({message:g.default.template(y.t("vxe.table.impSuccess"),[i.length]),status:"success"})):f&&y.modal.message({message:y.t("vxe.error.impFields"),status:"error"}),d&&(d(s),c._importResolve=null)},n.readAsBinaryString(t)}function a(e){if("xlsx"===e.options.type)return o(e),!1}function r(e){if("xlsx"===e.options.type)return n(e),!1}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginExportXLSX=void 0,g=t(g),h=t(h);var i={install:function(e){var t=e.interceptor;y=e,Object.assign(e.types,{xlsx:1}),t.mixin({"event.import":a,"event.export":r})}};e.VXETablePluginExportXLSX=i,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use(i);var s=i;e.default=s});
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define("vxe-table-plugin-export-xlsx",["exports","xe-utils","xlsx"],t);else if("undefined"!=typeof exports)t(exports,require("xe-utils"),require("xlsx"));else{var n={exports:{}};t(n.exports,e.XEUtils,e.XLSX),e.VXETablePluginExportXLSX=n.exports.default}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,g,h){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}var y;function n(e){var o="xlsx",a=e.$table,r=e.options,i=e.columns,t=e.datas,s=r.sheetName,l=r.isHeader,n=r.isFooter,u=r.original,f=r.footerFilterMethod,c=!1!==r.message,d={},p=[],m=[];l&&i.forEach(function(e){d[e.id]=u?e.property:e.getTitle(),m.push({wpx:g.default.toInteger(.8*e.renderWidth)})});var x=t.map(function(t){return i.forEach(function(e){t[e.id]=function(e,t){if(t)switch(e.cellType){case"string":break;case"number":if(!isNaN(t))return Number(t);break;default:if(t.length<12&&!isNaN(t))return Number(t)}return t}(e,t[e.id])}),t});if(n){var v=a.getTableData().footerData;(f?v.filter(f):v).forEach(function(n){var o={};i.forEach(function(e){var t;o[e.id]=(t=e,n[a.$getColumnIndex(t)])}),p.push(o)})}function b(){var e=h.default.utils.book_new(),t=h.default.utils.json_to_sheet((l?[d]:[]).concat(x).concat(p),{skipHeader:!0});t["!cols"]=m,h.default.utils.book_append_sheet(e,t,s);var n=h.default.write(e,{bookType:"xlsx",bookSST:!1,type:"binary"});!function(e,t){if(window.Blob){var n=t.filename,o=t.type;if(navigator.msSaveBlob)navigator.msSaveBlob(e,"".concat(n,".").concat(o));else{var a=document.createElement("a");a.target="_blank",a.download="".concat(n,".").concat(o),a.href=URL.createObjectURL(e),document.body.appendChild(a),a.click(),document.body.removeChild(a)}}else console.error(y.t("vxe.error.notExp"))}(new Blob([function(e){for(var t=new ArrayBuffer(e.length),n=new Uint8Array(t),o=0;o!==e.length;++o)n[o]=255&e.charCodeAt(o);return t}(n)],{type:"application/octet-stream"}),r),c&&(y.modal.close(o),y.modal.message({message:y.t("vxe.table.expSuccess"),status:"success"}))}c?(y.modal.message({id:o,message:y.t("vxe.table.expLoading"),status:"loading",duration:-1}),setTimeout(b,1500)):b()}function p(e){return e.replace(/^"/,"").replace(/"$/,"")}function o(e){var l=e.columns,u=e.options,t=e.file,f=!1!==u.message,c=e.$table,d=c._importResolve,n=new FileReader;n.onload=function(e){var t,n,o=h.default.read(e.target.result,{type:"binary"}),a=function(e){var t=e.split("\n"),o=[],a=[];if(t.length){var n=t.slice(1);t[0].split(",").map(p),n.forEach(function(e){if(e){var n={};e.split(",").forEach(function(e,t){o[t]&&(n[o[t]]=p(e))}),a.push(n)}})}return{fields:o,rows:a}}(h.default.utils.sheet_to_csv(o.Sheets.Sheet1)),r=a.fields,i=a.rows,s=(t=r,n=[],l.forEach(function(e){var t=e.property;t&&n.push(t)}),n.every(function(e){return t.includes(e)}));s?(c.createData(i).then(function(e){"append"===u.mode?c.insertAt(e,-1):c.reloadData(e)}),f&&y.modal.message({message:g.default.template(y.t("vxe.table.impSuccess"),[i.length]),status:"success"})):f&&y.modal.message({message:y.t("vxe.error.impFields"),status:"error"}),d&&(d(s),c._importResolve=null)},n.readAsBinaryString(t)}function a(e){if("xlsx"===e.options.type)return o(e),!1}function r(e){if("xlsx"===e.options.type)return n(e),!1}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginExportXLSX=void 0,g=t(g),h=t(h);var i={install:function(e){var t=e.interceptor;y=e,Object.assign(e.types,{xlsx:1}),t.mixin({"event.import":a,"event.export":r})}};e.VXETablePluginExportXLSX=i,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use(i);var s=i;e.default=s});
|
||||
6
index.ts
6
index.ts
@@ -81,13 +81,13 @@ function exportXLSX (params: InterceptorExportParams) {
|
||||
const exportMethod = () => {
|
||||
const book = XLSX.utils.book_new()
|
||||
const sheet = XLSX.utils.json_to_sheet((isHeader ? [colHead] : []).concat(rowList).concat(footList), { skipHeader: true })
|
||||
// 列宽
|
||||
// 设置列宽
|
||||
sheet['!cols'] = sheetCols
|
||||
// 转换数据
|
||||
XLSX.utils.book_append_sheet(book, sheet, sheetName)
|
||||
const wbout = XLSX.write(book, { bookType: 'xlsx', bookSST: false, type: 'binary' })
|
||||
const blob = new Blob([toBuffer(wbout)], { type: 'application/octet-stream' })
|
||||
// 保存导出
|
||||
// 导出 xlsx
|
||||
downloadFile(blob, options)
|
||||
if (showMsg) {
|
||||
_vxetable.modal.close(msgKey)
|
||||
@@ -96,7 +96,7 @@ function exportXLSX (params: InterceptorExportParams) {
|
||||
}
|
||||
if (showMsg) {
|
||||
_vxetable.modal.message({ id: msgKey, message: _vxetable.t('vxe.table.expLoading'), status: 'loading', duration: -1 })
|
||||
setTimeout(exportMethod, 1000)
|
||||
setTimeout(exportMethod, 1500)
|
||||
} else {
|
||||
exportMethod()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vxe-table-plugin-export-xlsx",
|
||||
"version": "1.3.12",
|
||||
"version": "1.5.0",
|
||||
"description": "基于 vxe-table 表格的增强插件,支持导出 xlsx 格式",
|
||||
"scripts": {
|
||||
"lib": "gulp build"
|
||||
|
||||
Reference in New Issue
Block a user