Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add CSV write buffer support#549

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
guyonroche merged 2 commits intoexceljs:masterfromgradecam:csv-writebuffer
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Add writeBuffer to csv
  • Loading branch information
Jared Butterfield authored andJarom Loveridge committedApr 19, 2018
commitae8a2dd5c08bd60424acba75243000444b270a9b
9 changes: 9 additions & 0 deletionslib/csv/csv.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ var fs = require('fs');
var csv = require('fast-csv');
var moment = require('moment');
var PromishLib = require('../utils/promish');
var StreamBuf = require('../utils/stream-buf');

var utils = require('../utils/utils');

Expand DownExpand Up@@ -166,5 +167,13 @@ CSV.prototype = {
var stream = fs.createWriteStream(filename, streamOptions);

return this.write(stream, options);
},
writeBuffer: function(options) {
var self = this;
var stream = new StreamBuf();
return self.write(stream, options)
.then(function() {
return stream.read();
});
}
};
19 changes: 19 additions & 0 deletionsspec/browser/exceljs.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,4 +66,23 @@ describe('ExcelJS', function() {
})
.catch(unexpectedError(done));
});
it('should write csv via buffer', function(done) {
var wb = new ExcelJS.Workbook();
var ws = wb.addWorksheet('blort');

ws.getCell('A1').value = 'Hello, World!';
ws.getCell('B1').value = 'What time is it?';
ws.getCell('A2').value = 7;
ws.getCell('B2').value = '12pm';

wb.csv.writeBuffer()
.then(function(buffer) {
expect(buffer.toString()).toEqual('"Hello, World!",What time is it?\n7,12pm')
done();
})
.catch(function(error) {
throw error;
})
.catch(unexpectedError(done));
});
});

[8]ページ先頭

©2009-2026 Movatter.jp