[Vuejs]-Getting just column data from xlsx file with vue.js

0👍

You can convert the data to json and then read the result, like this:

created() {
       var url = "/test.xlsx"  
       axios.get(url, {responseType:'arraybuffer'})
       .then((res) => {
                        var data = new Uint8Array(res.data)
                        var wb = XLSX.read(data, {type:"array"})
                        const firstSheetName = wb.SheetNames[0]
                        const first_worksheet = wb.Sheets[firstSheetName]
                        // convert to json
                        const file_data = XLSX.utils.sheet_to_json(first_worksheet, { header: 1 });
                        // first column first row value
                        console.log(file_data[0][0])
                        })
       .catch( err =>{this.err = err})
},

Leave a comment