2

I have this function in simple HTML page and that work 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 app I got error:

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

My xls files hold in 'static' folder.

I will be glad for any help.

Alexandr
  • 243
  • 2
  • 3
  • 15

1 Answers1

1

Firstly u need right import alasql

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

Secondly use form from Read and write Excel and raw data files

here my code:

<template>

</template>

<script>
import  alasql  from 'alasql';
alasql["private"].externalXlsxLib = require('xlsx');

export default {
    mounted(){      
 
 alasql.promise(
    "SELECT te  FROM XLSX('/MDF_PANELS.XLS') WHERE f = 13 ",[], ).then(function(results){
    console.log(results);
        }).catch(console.error);    
  }
    }
</script>

Where 'te' is the name of the required column and 'f' is the name of the required row