How to read an excel file contents on client side?

前端 未结 5 1801
小蘑菇
小蘑菇 2020-11-30 05:13

From the JSP page, I need to browse excel file and after selecting file on system, I need to read that excel file contents and fill my form.

Currently I have tried

5条回答
  •  隐瞒了意图╮
    2020-11-30 05:43

    This one works in all major browsers.

    https://catamphetamine.github.io/read-excel-file/

    
    
    import readXlsxFile from 'read-excel-file'
    
    const input = document.getElementById('input')
    
    input.addEventListener('change', () => {
      readXlsxFile(input.files[0]).then((data) => {
        // `data` is an array of rows
        // each row being an array of cells.
      })
    })
    

    In the example above data is raw string data. It can be parsed to JSON with a strict schema by passing schema argument. See API docs for an example of that.

    API docs: http://npmjs.com/package/read-excel-file

提交回复
热议问题