节点exceljs读取文件 [英] Node exceljs reading file

查看:173
本文介绍了节点exceljs读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,根据官方文档,我应该能够使用以下内容读取Excel文档:

So according to the offical documentation i should be able to read an excel document using:

    // read from a file 
var workbook = new Excel.Workbook();
workbook.xlsx.readFile(filename)
    .then(function() {
        // use workbook 
    });

// pipe from stream 
var workbook = new Excel.Workbook();
stream.pipe(workbook.xlsx.createInputStream());

我有以下文件:

我需要做的基本上是将每一行加载到一个对象中:

What i need to do is basicly to load each row into an object:

var excelObject = {competence1: '', competence2: ''}

然后将其保存到数组中.

And then save it into an array.

但是,文档并没有给我更多有关如何从此文件中读取内容的信息.它使用一个名为stream的变量,但是此变量在任何地方都没有解释.

However the documentation doesnt give me more on how i might read from this file. It uses a variable called stream however this variable is not explained anywhere.

有人知道这个插件并且知道我如何实现我的目标吗?

Does anyone know the plugin and know how i might achieve my goal?

推荐答案

var workbook = new Excel.Workbook(); 
workbook.xlsx.readFile(filename)
    .then(function() {
        var worksheet = workbook.getWorksheet(sheet);
        worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
          console.log("Row " + rowNumber + " = " + JSON.stringify(row.values));
        });
    });

这篇关于节点exceljs读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆