Commit 01e40eb2 authored by 何虹's avatar 何虹 💬

a

parent cae132f5
......@@ -169,7 +169,8 @@ import tbaleColumsSet from '../../common/tbaleColumsSet'
// import utilsExcel from '../../funTools/excel/utils_excel'
import rowTable from './rowTable'
import commonMixins from '../../ucClass/commonMixins'
import hsUtil from 'hs-util-js'
// import hsUtil from 'hs-util-js'
import uuT from './exportExcel'
export default {
mixins: [commonMixins],
components: {
......@@ -817,12 +818,12 @@ export default {
} else {
exportExcelData = result
}
hsUtil.ExcelModule.exportToExcel(tHeader, exportExcelData, exportExcelName)
uuT.exportToExcel(tHeader, exportExcelData, exportExcelName)
} else {
this.$message.warning('暂无数据~')
}
} else {
hsUtil.ExcelModule.exportToExcel(tHeader, data, exportExcelName)
uuT.exportToExcel(tHeader, data, exportExcelName)
}
},
rowCellBoolean(value) {
......
import XLSX from 'xlsx'
function exportToExcel(header, tabledata = [], fileName = '表') {
const list = []
const hList = []
// const key2List = []
header.forEach(item => {
const [key1] = item.split('=')
hList.push(key1)
})
tabledata.forEach(row => {
const obj = {}
header.forEach(item => {
const [key1, key2] = item.split('=')
obj[key1] = row[key2]
})
list.push(obj)
})
// 创建book
var wb = XLSX.utils.book_new()
// json转sheet
debugger
var ws = XLSX.utils.json_to_sheet(list, { header: hList })
// // 设置列宽
// ws['!cols'] = [
// { width: 15 },
// { width: 15 },
// { width: 15 },
// { width: 15 },
// { width: 10 }
// ]
// var timestamp = (new Date()).getTime()
// sheet写入book
XLSX.utils.book_append_sheet(wb, ws, 'file')
// 输出
XLSX.writeFile(wb, fileName + '.xlsx')
}
export default {
exportToExcel
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment