mirror of
https://gitee.com/x-extends/vxe-table-plugin-export-xlsx.git
synced 2026-01-21 05:21:33 +08:00
优化导出
This commit is contained in:
16
index.ts
16
index.ts
@@ -126,8 +126,8 @@ function exportXLSX (params: 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, headerExportMethod } = column
|
||||
colHead[id] = headerExportMethod ? headerExportMethod({ column, $table }) : (original ? field : column.getTitle())
|
||||
sheetCols.push({
|
||||
key: id,
|
||||
width: XEUtils.ceil(renderWidth / 8, 1)
|
||||
@@ -136,17 +136,17 @@ function exportXLSX (params: InterceptorExportParams) {
|
||||
// 处理表头
|
||||
if (isHeader) {
|
||||
// 处理分组
|
||||
if (isColgroup && !original && colgroups) {
|
||||
if (isColgroup && colgroups) {
|
||||
colgroups.forEach((cols, rIndex) => {
|
||||
const groupHead: any = {}
|
||||
columns.forEach((column) => {
|
||||
groupHead[column.id] = null
|
||||
})
|
||||
cols.forEach((column) => {
|
||||
const { _colSpan, _rowSpan } = column
|
||||
const { _colSpan, _rowSpan, headerExportMethod } = column
|
||||
const validColumn = getValidColumn(column)
|
||||
const columnIndex = columns.indexOf(validColumn)
|
||||
groupHead[validColumn.id] = original ? validColumn.property : column.getTitle()
|
||||
groupHead[validColumn.id] = headerExportMethod ? headerExportMethod({ column, $table }) : (original ? validColumn.field : column.getTitle())
|
||||
if (_colSpan > 1 || _rowSpan > 1) {
|
||||
sheetMerges.push({
|
||||
s: { r: rIndex, c: columnIndex },
|
||||
@@ -162,7 +162,7 @@ function exportXLSX (params: InterceptorExportParams) {
|
||||
beforeRowCount += colList.length
|
||||
}
|
||||
// 处理合并
|
||||
if (isMerge && !original) {
|
||||
if (isMerge) {
|
||||
mergeCells.forEach(mergeItem => {
|
||||
const { row: mergeRowIndex, rowspan: mergeRowspan, col: mergeColIndex, colspan: mergeColspan } = mergeItem
|
||||
sheetMerges.push({
|
||||
@@ -185,7 +185,7 @@ function exportXLSX (params: InterceptorExportParams) {
|
||||
const footers = getFooterData(options, footerData)
|
||||
const mergeFooterItems = $table.getMergeFooterItems()
|
||||
// 处理合并
|
||||
if (isMerge && !original) {
|
||||
if (isMerge) {
|
||||
mergeFooterItems.forEach(mergeItem => {
|
||||
const { row: mergeRowIndex, rowspan: mergeRowspan, col: mergeColIndex, colspan: mergeColspan } = mergeItem
|
||||
sheetMerges.push({
|
||||
@@ -367,7 +367,7 @@ function importXLSX (params: InterceptorImportParams) {
|
||||
fileReader.onload = (evnt) => {
|
||||
const tableFields: string[] = []
|
||||
columns.forEach((column) => {
|
||||
const field = column.property
|
||||
const field = column.field
|
||||
if (field) {
|
||||
tableFields.push(field)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vxe-table-plugin-export-xlsx",
|
||||
"version": "2.2.2",
|
||||
"version": "2.2.3",
|
||||
"description": "基于 vxe-table 的表格插件,支持导出 xlsx 格式",
|
||||
"scripts": {
|
||||
"lib": "gulp build"
|
||||
@@ -49,8 +49,8 @@
|
||||
"prettier": "^2.1.2",
|
||||
"typescript": "^4.6.4",
|
||||
"vue": "^2.6.14",
|
||||
"vxe-table": "^3.6.13",
|
||||
"xe-utils": "^3.5.7"
|
||||
"vxe-table": "^3.6.17",
|
||||
"xe-utils": "^3.5.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vxe-table": "^2.10.0 || ^3.2.0"
|
||||
|
||||
Reference in New Issue
Block a user