SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
https://sheetjs.com/
Apache License 2.0
35.02k stars 8k forks source link

Typo in README.md? #327

Closed cskaandorp closed 7 years ago

cskaandorp commented 8 years ago

Hi,

Great pacakage. I am a Meteor user and got into a lot of trouble with trying to write a workbook to a blob. In your description, under Writing Workbooks > Write to binary string, you have this piece of code:

function s2ab(s) {
  var buf = new ArrayBuffer(s.length);
  var view = new Uint8Array(buf);
  for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  return buf;
}

/* the saveAs call downloads a file on the local machine */
saveAs(new Blob([s2ab(wbout)],{type:""}), "test.xlsx")

I am most definitely not an expert!! But the code above did not work. Upon closer inspection I found it curious that 'buf' got returned and not 'view' in s2ab. When I changed buf into view, and removed the array-brackets over s2ab in the saveAs, everything worked.

As I said, I am an amateur, could you please review this?

Thanks,

Casper

reviewher commented 7 years ago

Hello Casper!

The code in the README was taken from http://sheetjs.com/demos/writexlsx.html . Can you check whether that demo works?

Actually, there is one difference in the saveAs line. Can you try:

saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), "test.xlsx")
cskaandorp commented 7 years ago

Hey Reviewher,

Thanks for getting back to me. I had this issue in December 2015, in the months after that I kind of ran away from Meteor. Sorry, I can't check try this anymore.

Good luck,

Cspr

reviewher commented 7 years ago

@cskaandorp what a glowing recommendation of meteor /s We'll wait for the next report