Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hs-sky-ui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何虹
hs-sky-ui
Commits
01e40eb2
Commit
01e40eb2
authored
Jan 18, 2021
by
何虹
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a
parent
cae132f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
child.vue
src/packages/hs-table/src/child.vue
+4
-3
exportExcel.js
src/packages/hs-table/src/exportExcel.js
+42
-0
No files found.
src/packages/hs-table/src/child.vue
View file @
01e40eb2
...
...
@@ -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
)
{
...
...
src/packages/hs-table/src/exportExcel.js
0 → 100644
View file @
01e40eb2
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment