Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csv to stream doesn't work #395

Closed
Imperat opened this issue Sep 8, 2017 · 0 comments
Closed

csv to stream doesn't work #395

Imperat opened this issue Sep 8, 2017 · 0 comments

Comments

@Imperat
Copy link
Contributor

Imperat commented Sep 8, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant