xlsx-to-table
无需上传,在浏览器中查看xlsx或xls表格,由js-xlsx驱动.
在vue-xlsx-table基础上开发,(为了获得完整表头)修改为即使某一列没有数据也获取表头,给列表默认空字符
依赖
用法
install
1
| npm install xlsx-to-table --save
|
main.js
1 2
| import xlsxToTable from 'xlsx-to-table' Vue.use(xlsxToTable, {rABS: false}) //浏览器的FileReader API 有两个方法可以读取本地文件 readAsBinaryString 和 readAsArrayBuffer, 默认rABS为false,也就是使用readAsArrayBuffer
|
file.vue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <template> <div id="app"> <h1>xlsx-to-table</h1> <xlsx-to-table @on-select-file="handleSelectedFile"></xlsx-to-table> </div> </template>
<script> export default { name: 'app', methods: { handleSelectedFile (convertedData) { console.log(convertedData) } } } </script>
|
开发
1 2
| npm run dev //develop npm run build //production
|