CSV with UTF8 BOM #650

Closed
opened 2017-05-09 19:08:13 +00:00 by charlesread · 2 comments
charlesread commented 2017-05-09 19:08:13 +00:00 (Migrated from github.com)

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: {} }
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 commented 2017-05-09 19:15:02 +00:00 (Migrated from github.com)

@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 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: ```js 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](https://github.com/SheetJS/js-xlsx/blob/master/test.js#L1651-L1659) to verify the line endings work properly. I also manually checked all three line endings (`\r`, `\n`, `\r\n`) against your sample: ```js > 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 commented 2017-05-09 20:12:05 +00:00 (Migrated from github.com)

Absolutely, I just emailed contact@. Thanks!

Absolutely, I just emailed contact@. Thanks!
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#650
No description provided.