From 7f9752362636fe5bb129c81a7f439dc8f7677ec6 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sun, 25 Sep 2022 11:36:48 +0800 Subject: [PATCH] fix --- .gitignore | 1 + gulpfile.js | 5 +++++ index.ts | 60 ++++++++++++++++++++++++++++------------------------ package.json | 21 +++++++++--------- 4 files changed, 49 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 997c6eb..47bdecd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.history node_modules /dist package-lock.json diff --git a/gulpfile.js b/gulpfile.js index 855806c..11587b9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,11 @@ const uglify = require('gulp-uglify') const babel = require('gulp-babel') const rename = require('gulp-rename') const replace = require('gulp-replace') +const dartSass = require('sass') +const gulpSass = require('gulp-sass') +const sass = gulpSass(dartSass) +const cleanCSS = require('gulp-clean-css') +const prefixer = require('gulp-autoprefixer') const sourcemaps = require('gulp-sourcemaps') const ts = require('gulp-typescript') const pack = require('./package.json') diff --git a/index.ts b/index.ts index f417b53..57df796 100644 --- a/index.ts +++ b/index.ts @@ -128,8 +128,8 @@ function exportXLSX (params: VxeGlobalInterceptorHandles.InterceptorExportParams let beforeRowCount = 0 const colHead: any = {} columns.forEach((column) => { - const { id, property, renderWidth } = column - colHead[id] = original ? property : column.getTitle() + const { id, field, renderWidth } = column + colHead[id] = original ? field : column.getTitle() sheetCols.push({ key: id, width: XEUtils.ceil(renderWidth / 8, 1) @@ -148,7 +148,7 @@ function exportXLSX (params: VxeGlobalInterceptorHandles.InterceptorExportParams const { _colSpan, _rowSpan } = column const validColumn = getValidColumn(column) const columnIndex = columns.indexOf(validColumn) - groupHead[validColumn.id] = original ? validColumn.property : column.getTitle() + groupHead[validColumn.id] = original ? validColumn.field : column.getTitle() if (_colSpan > 1 || _rowSpan > 1) { sheetMerges.push({ s: { r: rIndex, c: columnIndex }, @@ -246,18 +246,20 @@ function exportXLSX (params: VxeGlobalInterceptorHandles.InterceptorExportParams } excelRow.eachCell(excelCell => { const excelCol = sheet.getColumn(excelCell.col) - const column: any = $table.getColumnById(excelCol.key as string) - const { align } = column - setExcelCellStyle(excelCell, align || allAlign) - if (useStyle) { - Object.assign(excelCell, { - font: { - color: { - argb: defaultCellFontColor - } - }, - border: getDefaultBorderStyle() - }) + const column = $table.getColumnById(excelCol.key as string) + if (column) { + const { align } = column + setExcelCellStyle(excelCell, align || allAlign) + if (useStyle) { + Object.assign(excelCell, { + font: { + color: { + argb: defaultCellFontColor + } + }, + border: getDefaultBorderStyle() + }) + } } }) }) @@ -268,18 +270,20 @@ function exportXLSX (params: VxeGlobalInterceptorHandles.InterceptorExportParams } excelRow.eachCell(excelCell => { const excelCol = sheet.getColumn(excelCell.col) - const column: any = $table.getColumnById(excelCol.key as string) - const { footerAlign, align } = column - setExcelCellStyle(excelCell, footerAlign || align || allFooterAlign || allAlign) - if (useStyle) { - Object.assign(excelCell, { - font: { - color: { - argb: defaultCellFontColor - } - }, - border: getDefaultBorderStyle() - }) + const column = $table.getColumnById(excelCol.key as string) + if (column) { + const { footerAlign, align } = column + setExcelCellStyle(excelCell, footerAlign || align || allFooterAlign || allAlign) + if (useStyle) { + Object.assign(excelCell, { + font: { + color: { + argb: defaultCellFontColor + } + }, + border: getDefaultBorderStyle() + }) + } } }) }) @@ -362,7 +366,7 @@ function importXLSX (params: VxeGlobalInterceptorHandles.InterceptorImportParams fileReader.onload = (evnt) => { const tableFields: string[] = [] columns.forEach((column) => { - const field = column.property + const field = column.field if (field) { tableFields.push(field) } diff --git a/package.json b/package.json index 0a86cdb..26f06fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table-plugin-export-xlsx", - "version": "3.0.3", + "version": "3.0.4", "description": "基于 vxe-table 的表格插件,支持导出 xlsx 格式", "scripts": { "lib": "gulp build" @@ -33,24 +33,25 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.2", "eslint-plugin-typescript": "^0.14.0", - "exceljs": "^4.2.0", + "exceljs": "^4.3.0", "gulp": "^4.0.2", - "gulp-autoprefixer": "^7.0.1", + "gulp-autoprefixer": "^8.0.0", "gulp-babel": "^8.0.0", "gulp-clean-css": "^4.3.0", "gulp-concat": "^2.6.1", "gulp-rename": "^2.0.0", - "gulp-replace": "^1.0.0", - "gulp-sass": "^4.1.0", - "gulp-sourcemaps": "^2.6.5", + "gulp-replace": "^1.1.3", + "gulp-sass": "^5.1.0", + "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^5.0.1", "gulp-uglify": "^3.0.2", "markdown-doctest": "^1.1.0", "prettier": "^2.1.2", - "typescript": "^4.0.5", - "vue": "^3.2.14", - "vxe-table": "^4.0.28", - "xe-utils": "^3.4.0" + "sass": "^1.55.0", + "typescript": "^4.6.4", + "vue": "^3.2.39", + "vxe-table": "^4.3.5", + "xe-utils": "^3.5.6" }, "peerDependencies": { "vxe-table": "^4.0.27"