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 with UTF8 BOM #650

Closed
charlesread opened this issue May 9, 2017 · 2 comments
Closed

CSV with UTF8 BOM #650

charlesread opened this issue May 9, 2017 · 2 comments

Comments

@charlesread
Copy link

I greatly appreciate the effort in #648! But now the XLSX.readFile() returned object is just

{ Sheets: {},
  SheetNames: [],
  Workbook: { Sheets: [] },
  SSF: 
   { '0': 'General',
     '1': '0',
     '2': '0.00',
     '3': '#,##0',
     '4': '#,##0.00',
     '9': '0%',
     '10': '0.00%',
     '11': '0.00E+00',
     '12': '# ?/?',
     '13': '# ??/??',
     '14': 'm/d/yy',
     '15': 'd-mmm-yy',
     '16': 'd-mmm',
     '17': 'mmm-yy',
     '18': 'h:mm AM/PM',
     '19': 'h:mm:ss AM/PM',
     '20': 'h:mm',
     '21': 'h:mm:ss',
     '22': 'm/d/yy h:mm',
     '37': '#,##0 ;(#,##0)',
     '38': '#,##0 ;[Red](#,##0)',
     '39': '#,##0.00;(#,##0.00)',
     '40': '#,##0.00;[Red](#,##0.00)',
     '45': 'mm:ss',
     '46': '[h]:mm:ss',
     '47': 'mmss.0',
     '48': '##0.0E+0',
     '49': '@',
     '56': '"上午/下午 "hh"時"mm"分"ss"秒 "',
     '65535': 'General' },
  Props: {},
  Custprops: {} }
@SheetJSDev
Copy link
Contributor

@charlesread can you share the actual file (either email the raw file or zip it and upload to github)? If I understood the issue, this should be reproducing the original file:

var data = "1,charles\r\n2,cricket\r\n3,ladybug\r\n4,sara\r\n";
require('xlsx').read(data, {type:"binary"});

We added tests to the suite to verify the line endings work properly.

I also manually checked all three line endings (\r, \n, \r\n) against your sample:

> require('xlsx').version
'0.10.0'
> require('xlsx').read("1,charles\r2,cricket\r3,ladybug\r4,sara\r", {type:"binary"}).Sheets.Sheet1
{ A1: { t: 'n', w: '1', v: 1 },
  B1: { t: 's', v: 'charles' },
  A2: { t: 'n', w: '2', v: 2 },
  B2: { t: 's', v: 'cricket' },
  A3: { t: 'n', w: '3', v: 3 },
  B3: { t: 's', v: 'ladybug' },
  A4: { t: 'n', w: '4', v: 4 },
  B4: { t: 's', v: 'sara' },
  '!ref': 'A1:B4' }
> require('xlsx').read("1,charles\r\n2,cricket\r\n3,ladybug\r\n4,sara\r\n", {type:"binary"}).Sheets.Sheet1
{ A1: { t: 'n', w: '1', v: 1 },
  B1: { t: 's', v: 'charles' },
  A2: { t: 'n', w: '2', v: 2 },
  B2: { t: 's', v: 'cricket' },
  A3: { t: 'n', w: '3', v: 3 },
  B3: { t: 's', v: 'ladybug' },
  A4: { t: 'n', w: '4', v: 4 },
  B4: { t: 's', v: 'sara' },
  '!ref': 'A1:B4' }
> require('xlsx').read("1,charles\n2,cricket\n3,ladybug\n4,sara\n", {type:"binary"}).Sheets.Sheet1
{ A1: { t: 'n', w: '1', v: 1 },
  B1: { t: 's', v: 'charles' },
  A2: { t: 'n', w: '2', v: 2 },
  B2: { t: 's', v: 'cricket' },
  A3: { t: 'n', w: '3', v: 3 },
  B3: { t: 's', v: 'ladybug' },
  A4: { t: 'n', w: '4', v: 4 },
  B4: { t: 's', v: 'sara' },
  '!ref': 'A1:B4' }

@charlesread
Copy link
Author

Absolutely, I just emailed contact@. Thanks!

@SheetJSDev SheetJSDev changed the title #648 not fixed CSV with UTF8 BOM May 9, 2017
RimaCiklum pushed a commit to Folcon/js-xlsx that referenced this issue Aug 20, 2020
- SSF update to address extendscript issue (fixes SheetJS#608 h/t @mjdb3d)
- XLSX cellDates set date format (fixes SheetJS#647 h/t @psalmody)
- ODS add stub stylesheet for Excel (fixes SheetJS#649 h/t @WaqasJaved1)
- CSV with UTF8 BOM (fixes SheetJS#650 h/t @charlesread)
- DIF/CSV fuzzy date speculation
- SYLK parse RC formulae
- CSF utils for manipulating workbooks
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