Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
founder_vue
Overview
Overview
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
常超
founder_vue
Commits
648ba81e
Commit
648ba81e
authored
Oct 31, 2023
by
xue_wengang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
htmlToExcel
parent
79f52047
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/excel/htmlToExcel.js
+28
-0
src/main.js
+2
-0
No files found.
src/excel/htmlToExcel.js
0 → 100644
View file @
648ba81e
import
FileSaver
from
'file-saver'
;
import
XLSX
from
'xlsx'
;
export
default
{
// 导出Excel表格
exportExcel
(
name
,
tableName
)
{
debugger
//name表示生成excel的文件名 tableName表示表格的id
let
fix
=
document
.
querySelector
(
'.el-table__fixed'
);
//let con = document.querySelector(tableName);
//console.log(con);
let
sel
;
if
(
fix
){
//判断要导出的节点中是否有fixed的表格,如果有,转换excel时先将该dom移除,然后append回去
sel
=
XLSX
.
utils
.
table_to_book
(
document
.
querySelector
(
'#myTable'
).
removeChild
(
fix
));
document
.
querySelector
(
'#myTable'
).
appendChild
(
fix
);
}
else
{
sel
=
XLSX
.
utils
.
table_to_book
(
document
.
querySelector
(
tableName
));
}
//var sel = XLSX.utils.table_to_book(document.querySelector(tableName))
var
selIn
=
XLSX
.
write
(
sel
,
{
bookType
:
'xlsx'
,
bookSST
:
true
,
type
:
'array'
})
try
{
FileSaver
.
saveAs
(
new
Blob
([
selIn
],
{
type
:
'application/octet-stream'
}),
name
)
}
catch
(
e
)
{
if
(
typeof
console
!==
'undefined'
)
console
.
log
(
e
,
selIn
)
}
return
selIn
}
};
src/main.js
View file @
648ba81e
...
...
@@ -21,6 +21,8 @@ import moment from 'moment'
import
rules
from
"./utils/rules.js"
;
import
baseUrl
from
'./api/base'
const
Base64
=
require
(
'js-base64'
).
Base64
import
htmlToExcel
from
'./excel/htmlToExcel'
;
Vue
.
prototype
.
htmlToExcels
=
htmlToExcel
;
//引入echarts
import
echarts
from
'echarts'
...
...
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