mirror of
https://gitee.com/x-extends/vxe-table-plugin-export-xlsx.git
synced 2026-01-21 05:21:33 +08:00
update
This commit is contained in:
11
index.ts
11
index.ts
@@ -2,6 +2,13 @@ import XEUtils from 'xe-utils/methods/xe-utils'
|
||||
import VXETable from 'vxe-table/lib/vxe-table'
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
function getSeq($table: any, row: any, rowIndex: number, column: any, columnIndex: number) {
|
||||
// 在 v3.0 中废弃 startIndex、indexMethod
|
||||
let seqOpts = $table.seqOpts
|
||||
let seqMethod = seqOpts.seqMethod || column.indexMethod
|
||||
return seqMethod ? seqMethod({ row, rowIndex, column, columnIndex }) : ((seqOpts.startIndex || $table.startIndex) + rowIndex + 1)
|
||||
}
|
||||
|
||||
function toBuffer(wbout: any) {
|
||||
let buf = new ArrayBuffer(wbout.length)
|
||||
let view = new Uint8Array(buf)
|
||||
@@ -24,9 +31,9 @@ function exportXLSX(params: any) {
|
||||
columns.forEach((column: any, columnIndex: number) => {
|
||||
let cellValue
|
||||
const property = column.property
|
||||
const isIndex = column.type === 'index'
|
||||
const isIndex = column.type === 'seq' || column.type === 'index'
|
||||
if (!original || isIndex) {
|
||||
cellValue = isIndex ? (column.indexMethod ? column.indexMethod({ row, rowIndex, column, columnIndex }) : rowIndex + 1) : row[column.id]
|
||||
cellValue = isIndex ? getSeq($table, row, rowIndex, column, columnIndex) : row[column.id]
|
||||
} else {
|
||||
cellValue = XEUtils.get(row, property)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user