首页 > 解决方案 > 如何读取上传的excel文件并以角度转换为json

问题描述

关于如何读取上传的excel文件并以角度转换为json的人可以提供帮助吗?谢谢你。

标签: angular

解决方案


https://www.npmjs.com/package/read-excel-file使用这个 npm 包。

安装

npm install read-excel-file --save

在 html 中

<input type="file" id="input" />

ts

import readXlsxFile from 'read-excel-file'

const input = document.getElementById('input')

input.addEventListener('change', () => {
  readXlsxFile(input.files[0]).then((rows) => {
    // `rows` is an array of rows
    // each row being an array of cells.
  })
})

演示


推荐阅读