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
Closed

CSV file seems different depending on the program. #1024

hyeribo opened this issue Mar 7, 2018 · 2 comments

Comments

@hyeribo
Copy link

hyeribo 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
Copy link
Contributor

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
Copy link
Author

hyeribo commented Mar 19, 2018

It works. Thanks!!

RimaCiklum pushed a commit to Folcon/js-xlsx that referenced this issue Aug 20, 2020
- add BOM to `stream.to_csv` (fixes SheetJS#1024 h/t @hr5959)
- `utils.format_cell` type (h/t @victorj2307)
- duktape niggles
- demo cleanup
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

2 participants