tlqylzn / export-to-excel Goto Github PK
View Code? Open in Web Editor NEW自定义导出excel
License: MIT License
自定义导出excel
License: MIT License
如题。
const exportToExcel = require('export-to-excel');
const sampleData = [
{
subscribe: 1,
openid: 'o7Zv3s_F0N3-h09fLN3jOIM8WNwzsdsdsdo',
nickname: 'name1',
sex: 1,
language: 'zh_CN',
city: '杭州',
province: '浙江',
country: '**',
headimgurl: 'http://wx.qlogo.cn/mmopen/s3NiblUuUDR7y3s1DsZibAja25icOumEM4KM79w8pKB5g0o2KKvVDWAqtVuCNVicZIzcqWzOS32ueOvD7tjmRVj2zQ/0',
subscribe_time: 1439719607
},
{
subscribe: 1,
openid: 'o7Zv3sz92svh2lv_mMg1wewejY0OpU3Q8',
nickname: 'name2',
sex: 1,
language: 'zh_CN',
city: '南京',
province: '江苏',
country: '**',
headimgurl: 'http://wx.qlogo.cn/mmopen/PiajxSqBRaELAI1aEUyI3lwJdMwibicvlkF8ASmIhicSYg3n29v2yHibmum2ibmvedvuXnrziaBl46mnrZe6Cb4pSMaXw/0',
subscribe_time: 1431691451
},
{
subscribe: 0,
openid: 'o7Zv3s5yjT2MDIICMZkcvcvcvLG71dyBDlg',
nickname: 'name3',
sex: 1,
language: 'zh_CN',
city: '浦东新区',
province: '上海',
country: '**',
headimgurl: 'http://wx.qlogo.cn/mmopen/PiajxSqBRaELt5V5lD4ficPFvT2Z0ZDOHKc26BHh43NXT41WKFQUzLcdtgvBWn1jcqDSac1ib8PpsezuicNVVcbcicA/0',
subscribe_time: 1442406029
}
]
exportToExcel.exportXLSX({
filename: '微信粉丝列表(2016-01-01)',
sheetname: '微信粉丝列表',
title: [
{
fieldName: 'subscribe',
displayName: '是否关注',
cellWidth: 8,
type: 'bool' // 1:是 0:否
},
{
fieldName: 'openid',
displayName: 'OpenID',
cellWidth: 30
},
{
fieldName: 'nickname',
displayName: '昵称',
cellWidth: 15
},
{
fieldName: 'sex',
displayName: '性别',
cellWidth: 6,
type: 'sex' // 1:男 0:女
},
{
fieldName: 'language',
displayName: '语言',
cellWidth: 8
},
{
fieldName: 'city',
displayName: '城市',
cellWidth: 12
},
{
fieldName: 'province',
displayName: '省',
cellWidth: 10
},
{
fieldName: 'country',
displayName: '国家',
cellWidth: 10
},
{
fieldName: 'headimgurl',
displayName: '头像',
cellWidth: 20
},
{
fieldName: 'subscribe_time',
displayName: '关注时间',
cellWidth: 20,
type: 'datetime' // 2015-12-12 10:00:00
}
],
data: sampleData
})
ERROR in ./~/moment/moment.js
Module build failed: Error: ENOENT: no such file or directory, open '项目目录\node_modules\moment\moment.js'
at Error (native)
@ ./~/export-to-excel/lib/excel/xlsx.js 12:14-31
@ ./~/export-to-excel/lib/excel/index.js
@ ./~/export-to-excel/lib/index.js
@ ./~/export-to-excel/index.js
@ ./~/.npminstall/babel-loader/6.2.10/babel-loader/lib!./~/.npminstall/vue-loader/10.3.0/vue-loader/lib/selector.js?type=script&index=0!./src/views/site-manage/index.vue
@ ./src/views/site-manage/index.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
ERROR in ./~/export-to-excel/lib/excel/xlsx.js
Module not found: Error: Can't resolve 'debug' in '项目目录\node_modules\export-to-excel\lib\excel'
@ ./~/export-to-excel/lib/excel/xlsx.js 16:13-29
@ ./~/export-to-excel/lib/excel/index.js
@ ./~/export-to-excel/lib/index.js
@ ./~/export-to-excel/index.js
@ ./src/router/index.js
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
ERROR in ./~/xlsx/xlsx.js
Module build failed: Error: ENOENT: no such file or directory, open 'D:\intvstatic\xxxx\项目目录\node_modules\xlsx\xlsx.js'
at Error (native)
@ ./~/export-to-excel/lib/excel/xlsx.js 8:12-27
@ ./~/export-to-excel/lib/excel/index.js
@ ./~/export-to-excel/lib/index.js
@ ./~/export-to-excel/index.js
是你的项目依赖本身有问题吗? 我的node 版本是6.9.2
能不能增加导出成功后的回调函数,callback或者promise
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.