This commit is contained in:
xuliangzhan
2024-10-17 11:31:11 +08:00
parent 2e9ca4f389
commit 0a80c1acf0
2 changed files with 3 additions and 3 deletions

View File

@@ -390,12 +390,12 @@ function importXLSX (params: VxeGlobalInterceptorHandles.InterceptorImportParams
workbook.xlsx.load(readerTarget.result as ArrayBuffer).then(wb => { workbook.xlsx.load(readerTarget.result as ArrayBuffer).then(wb => {
const firstSheet = wb.worksheets[0] const firstSheet = wb.worksheets[0]
if (firstSheet) { if (firstSheet) {
const sheetValues = firstSheet.getSheetValues() as string[][] const sheetValues = Array.from(firstSheet.getSheetValues()) as string[][]
const fieldIndex = XEUtils.findIndexOf(sheetValues, (list) => list && list.length > 0) const fieldIndex = XEUtils.findIndexOf(sheetValues, (list) => list && list.length > 0)
const fields = sheetValues[fieldIndex] as string[] const fields = sheetValues[fieldIndex] as string[]
const status = checkImportData(tableFields, fields) const status = checkImportData(tableFields, fields)
if (status) { if (status) {
const records = sheetValues.slice(fieldIndex).map(list => { const records = sheetValues.slice(fieldIndex + 1).map(list => {
const item : any = {} const item : any = {}
list.forEach((cellValue, cIndex) => { list.forEach((cellValue, cIndex) => {
item[fields[cIndex]] = cellValue item[fields[cIndex]] = cellValue

View File

@@ -1,6 +1,6 @@
{ {
"name": "vxe-table-plugin-export-xlsx", "name": "vxe-table-plugin-export-xlsx",
"version": "4.0.6", "version": "4.0.7",
"description": "基于 vxe-table 表格的扩展插件,支持导出 xlsx 格式", "description": "基于 vxe-table 表格的扩展插件,支持导出 xlsx 格式",
"scripts": { "scripts": {
"lib": "gulp build" "lib": "gulp build"