如何同时读写?

时间:2019-08-12 10:53:32

标签: node.js js-xlsx

我想读写Excel文件。但我不希望他将数据写入他读取的文件中。

    var Excel = require('exceljs');
    var workbook = new Excel.Workbook();

    workbook.xlsx.readFile("test.xlsx").then(function () {

        var worksheet=workbook.getWorksheet('Sheet1');

        var row=worksheet.getRow(1);
        var cell=row.getCell(1).toString();
        var cell1=row.getCell(2).toString();

        console.log(cell+" "+cell1);

    });

    workbook.xlsx.writeFile("yazdir.xlsx").then(function() {
            var worksheet=workbook.getWorksheet('Sheet1');
            var row=worksheet.getRow(1);
            row.getCell(2).value = "getcell value"; //  
            row.commit();
            return workbook.xlsx.writeFile("yazdir.xlsx");

    });

我的期望:https://ibb.co/NFVSxqX

我的结果:https://ibb.co/hZmpDQd

我的test.xlsx文件:https://ibb.co/SyXw8NR

0 个答案:

没有答案