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 file seems different depending on the program. #1024

Closed
hyeribo opened this issue Mar 7, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@hyeribo
Copy link

commented Mar 7, 2018

I made a csv file:
var stream = XLSX.stream.to_csv(ws);
stream.pipe(fs.createWriteStream(fileName));

then uploaded the file to S3 and returned url.

When I download the file and open it, it looks well on my pc. (open on OS X using Numbers.)
But when I trying to open the same file on window OS using ms office, characters are broken.
it's Korean characters. and I want to encode the file UTF-8.
How can I resolve this problem?

it's the file.
20180307105408.csv.zip

@SheetJSDev

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2018

The utility currently doesn't (but should) write the UTF8 BOM. As a temporary workaround:

var stream = XLSX.stream.to_csv(ws);
var out = fs.createWriteStream(fileName);
out.on('open', function(fd) {
  out.write(new Buffer([0xEF,0xBB,0xBF]));
  stream.pipe(out);
});

If you would like to contribute a fix, in the write_csv_stream function add a line to push the BOM if it hasn't been written:

var BOM = false;
stream._read = function() {
	if(!BOM) { BOM = true; return stream.push("\uFEFF"); }
@hyeribo

This comment has been minimized.

Copy link
Author

commented Mar 19, 2018

It works. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.