一、问题描述:
在浏览器在线预览xls,需要引入2个模块,所以本人整理上传npm。开发时只需要引入vue-excelview即可
vue-excelview
二、参考
此npm模块开发用到相关资料
三、npm模块源代码(已封装的Vue组件):
v-for="(item, index) in sheetNames"
:key="index"
:type="sheetActive===item?'primary':''"
@click="onTabWorkbook(index)">
{ {item}}
import XLSX from 'xlsx' // 预览
import canvasDatagrid from 'canvas-datagrid'
export default {
name: 'excel',
props: {
datas: null
},
data () {
return {
excelGridData: [],
excelGridDom: null,
workbook: null,
sheets: [],
sheetNames: [],
sheetActive: ''
}
},</