Excel to JSON javascript code?

后端 未结 4 1071
予麋鹿
予麋鹿 2020-12-04 13:03

I want to convert excel sheet data to json. It has to be dynamic, so there is an upload button where user uploads the excel sheet and the data is then converted into json. C

4条回答
  •  悲&欢浪女
    2020-12-04 13:26

    @Kwang-Chun Kang Thanks Kang a lot! I found the solution is working and very helpful, it really save my day. For me I am trying to create a React.js component that convert *.xlsx to json object when user upload the excel file to a html input tag. First I need to install XLSX package with:

    npm install xlsx --save
    

    Then in my component code, import with:

    import XLSX from 'xlsx'
    

    The component UI should look like this:

    
    

    It calls a function fileReader(), which is exactly same as the solution provided. To learn more about fileReader API, I found this blog to be helpful: https://blog.teamtreehouse.com/reading-files-using-the-html5-filereader-api

提交回复
热议问题