Guide to importing data from Excel files in Nuxt Vue.js applications
P粉714890053
P粉714890053 2024-03-26 18:49:23
0
1
428

I have this functionality in a simple HTML page and it works fine

head () {
        return {
          script: [
            {
              hid: 'alasql',
              src: 'https://cdn.jsdelivr.net/alasql/0.3/alasql.min.js',
              defer: true,
              //callback: () => { this.isStripeLoaded = true } 
            },  
            {
              hid: 'ajax',
              src: 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.core.min.js',
              defer: true,
            
              
            }
          ]
        }
    },
  mounted(){

     function setPrice(nomer){
                    var printResult = function(result){ 
                            console.log(result[0].te)
                            // var sum= result[0].te
      
                        };
                        
        alasql ("SELECT te  FROM XLSX('/MDF_PANELS.XLS') WHERE f = "+nomer+"",[],
            function (data) {printResult(data);})                       
      }
}

But when I move to nuxt application I get the error:

Invalid HTML: could not find <table>
    at e (xlsx.core.min.js:16)

My xls files are saved in the "static" folder.

I would be happy to get any help.

P粉714890053
P粉714890053

reply all(1)
P粉547362845

First you need to import alasql correctly

import * as alasql from 'alasql';
alasql["private"].externalXlsxLib = require('xlsx');

Secondly use to read and write form Excel and raw data files

This is my code:



sssccc

where "te" is the name of the desired column and "f" is the name of the desired row

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!