Skip to content

csv to stream doesn't work #395

Closed
Closed
@Imperat

Description

@Imperat

Hi, guys! Thank you for you open source library. In the last week I had task to export some data in excel document. I use this small code:

const Excel = require('exceljs');
const Readable = require('stream').Readable;
const Writable = require('stream').Writable;

const stream2n = new Writable();
stream2n.result = [];
stream2n._write = function (chunk, enc, next) {
  this.result.push(chunk);
};

const stream1n = new Readable();
stream1n._read = function () {
  stream1n.push(stream2n.result.shift() || null);
};

const workbook = new Excel.Workbook();
const pageName = 'Page name';
workbook.addWorksheet(pageName);

workbook.getWorksheet(pageName).addRow([1, 2, 3, 4, 5]);
let promise2 = new Promise((resolve, reject) => {
  
  workbook.xlsx.write(stream2n).then(() => {
    setTimeout(() => console.log('RESOLVED!'), 500);
    resolve(true);
  });
});

console.log('AT THE END');

It works nice, but now I have task to import doc as csv file. I change just one line:
workbook.xlsx.write(stream2n).then(() => { I change with:
workbook.csv.write(stream2n).then(() => {
But now read stream will never closed. Have you any advice how I can fix it? It seems that this is the bug of exceljs. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions