Reading Excel file using node.js

前端 未结 6 1438
遥遥无期
遥遥无期 2020-11-28 05:38

Okay so i am using the FileUploader module to upload my file from angular to my REST API:

var uploader = $scope.uploader = new File         


        
6条回答
  •  猫巷女王i
    2020-11-28 06:20

    You can use read-excel-file npm.

    In that, you can specify JSON Schema to convert XLSX into JSON Format.

    const readXlsxFile = require('read-excel-file/node');
    
    const schema = {
        'Segment': {
            prop: 'Segment',
            type: String
        },
        'Country': {
            prop: 'Country',
            type: String
        },
        'Product': {
            prop: 'Product',
            type: String
        }
    }
    
    readXlsxFile('sample.xlsx', { schema }).then(({ rows, errors }) => {
        console.log(rows);
    });
    

提交回复
热议问题