sheet_to_row_object_array(sheet) crashes when looping through sheetnames #4

Closed
opened 2013-03-01 11:16:08 +00:00 by artiee · 4 comments
artiee commented 2013-03-01 11:16:08 +00:00 (Migrated from github.com)

The following code crashes

var XLSX = require('xlsx')
var xlsx = XLSX.readFile('test.xlsx')

xlsx.SheetNames.forEach(function(sheetName) {

  // this works if sheetname is given:
  // var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets["3AU"])

// this crashes:
  var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets[sheetName])

  console.log(parsedSheet)

})

C:\IS\node\node_modules\xlsx\xlsx.js:338
if (sheet["!ref"]) {
^
TypeError: Cannot read property '!ref' of undefined
at Object.sheet_to_row_object_array (C:\IS\node\node_modules\xlsx\xlsx.js:338:11)
at C:\IS\node\testapp\app3.js:9:32
at Array.forEach (native)
at Object. (C:\IS\node\testapp\app3.js:5:17)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

The following code crashes ``` javascript var XLSX = require('xlsx') var xlsx = XLSX.readFile('test.xlsx') xlsx.SheetNames.forEach(function(sheetName) { // this works if sheetname is given: // var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets["3AU"]) // this crashes: var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets[sheetName]) console.log(parsedSheet) }) ``` C:\IS\node\node_modules\xlsx\xlsx.js:338 if (sheet["!ref"]) { ^ TypeError: Cannot read property '!ref' of undefined at Object.sheet_to_row_object_array (C:\IS\node\node_modules\xlsx\xlsx.js:338:11) at C:\IS\node\testapp\app3.js:9:32 at Array.forEach (native) at Object.<anonymous> (C:\IS\node\testapp\app3.js:5:17) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Niggler commented 2013-03-01 22:12:29 +00:00 (Migrated from github.com)
  1. Can you share a file that exhibits this problem?

  2. can you console.log(sheetName) for the version that crashes?

  3. can you test with https://www.dropbox.com/s/2l8q76x6x75e13t/interview.xlsx (contributed by @nathanathan https://github.com/Niggler/js-xlsx/issues/2 )?

I tested with the interview file and some other files I have on my machine and I can't elicit the problem. For example, with the interview.xlsx, I see:

$ cat test.js
var XLSX = require('xlsx'), xlsx = XLSX.readFile('interview.xlsx');

xlsx.SheetNames.forEach(function(sheetName) { console.log(XLSX.utils.sheet_to_row_object_array(xlsx.Sheets[sheetName])); });

$ node test.js
[ { name: 'start',
    label: 'How would you characterize your experience as an interviewer/interviewee?',
    tags: 'exp_tags' },
  { name: 'purposes',
    label: 'What are some of the purposes of the interviews you\'ve been involved in? (data gathering, recruiting, health diagnostics, investigative journalism)',
    tags: 'none' },
  { name: 'duration',
    label: 'How long do your interviews usually last? Did you usually have an idea of how far along you are in the interview?' },
  { name: 'sittings',
    label: 'Have you participated in interviews that took place over multiple sittings? Does this seem to be a common case?' },
  { name: 'medium',
    label: 'Have your interviews been in person? on the phone? written response?' },
  { name: 'admin',
    label: 'Have you been involved in any interviewing projects in an administrative capacity? What tasks did you perform?',
    tags: 'admin_tasks' },
  { type: 'begin branch',
    label: 'Administrative experience follow-up questions.' },
  { name: 'challenges',
    label: 'Which tasks do you find the most challenging or time consuming?' },
  { name: 'experience',
    label: 'What level of training or experience is typically required in your interviews?' },
  { name: 'branching',
    label: 'Have you administered any interviews with branching logic?' },
  { name: 'follow-ups',
    label: 'Do you tend to ask follow-up questions beyond what is suggested in the survey?\r\nHow/when do they usually occur? How are they dealt with in coding?' },
  { name: 'recording',
    label: 'Are your interviews recorded?\r\nHave you encountered any limitations in being allowed to record?' },
  { name: 'notes',
    label: 'Do you take notes during your interviews?' },
  { name: 'contingencies',
    label: 'Have you ever needed to discard recordings/notes that you collected?' },
  { type: 'end branch' },
  { type: 'begin branch', label: 'No administrative experience.' },
  { type: 'end branch' },
  { name: 'comments',
    label: 'Do you have any comments about the tool I am using? About the interview experience as a whole?' } ]
[ { group: 'default', name: 'important', label: 'important' },
  { group: 'default', name: 'tangential', label: 'tangential' },
  { group: 'default', name: 'star', imagePath: 'star.png' },
  { group: 'admin_tasks',
    name: 'interview designer',
    label: 'interview designer' },
  { group: 'admin_tasks',
    name: 'interviewer',
    label: 'interviewer' },
  { group: 'admin_tasks',
    name: 'datas analysis',
    label: 'datas analysis' },
  { group: 'exp_tags',
    name: 'highly experienced interviewer',
    label: 'highly experienced interviewer' },
  { group: 'exp_tags',
    name: 'highly experienced interviewee',
    label: 'highly experienced interviewee' } ]
1) Can you share a file that exhibits this problem? 2) can you `console.log(sheetName)` for the version that crashes? 3) can you test with https://www.dropbox.com/s/2l8q76x6x75e13t/interview.xlsx (contributed by @nathanathan https://github.com/Niggler/js-xlsx/issues/2 )? I tested with the interview file and some other files I have on my machine and I can't elicit the problem. For example, with the interview.xlsx, I see: ``` $ cat test.js var XLSX = require('xlsx'), xlsx = XLSX.readFile('interview.xlsx'); xlsx.SheetNames.forEach(function(sheetName) { console.log(XLSX.utils.sheet_to_row_object_array(xlsx.Sheets[sheetName])); }); $ node test.js [ { name: 'start', label: 'How would you characterize your experience as an interviewer/interviewee?', tags: 'exp_tags' }, { name: 'purposes', label: 'What are some of the purposes of the interviews you\'ve been involved in? (data gathering, recruiting, health diagnostics, investigative journalism)', tags: 'none' }, { name: 'duration', label: 'How long do your interviews usually last? Did you usually have an idea of how far along you are in the interview?' }, { name: 'sittings', label: 'Have you participated in interviews that took place over multiple sittings? Does this seem to be a common case?' }, { name: 'medium', label: 'Have your interviews been in person? on the phone? written response?' }, { name: 'admin', label: 'Have you been involved in any interviewing projects in an administrative capacity? What tasks did you perform?', tags: 'admin_tasks' }, { type: 'begin branch', label: 'Administrative experience follow-up questions.' }, { name: 'challenges', label: 'Which tasks do you find the most challenging or time consuming?' }, { name: 'experience', label: 'What level of training or experience is typically required in your interviews?' }, { name: 'branching', label: 'Have you administered any interviews with branching logic?' }, { name: 'follow-ups', label: 'Do you tend to ask follow-up questions beyond what is suggested in the survey?\r\nHow/when do they usually occur? How are they dealt with in coding?' }, { name: 'recording', label: 'Are your interviews recorded?\r\nHave you encountered any limitations in being allowed to record?' }, { name: 'notes', label: 'Do you take notes during your interviews?' }, { name: 'contingencies', label: 'Have you ever needed to discard recordings/notes that you collected?' }, { type: 'end branch' }, { type: 'begin branch', label: 'No administrative experience.' }, { type: 'end branch' }, { name: 'comments', label: 'Do you have any comments about the tool I am using? About the interview experience as a whole?' } ] [ { group: 'default', name: 'important', label: 'important' }, { group: 'default', name: 'tangential', label: 'tangential' }, { group: 'default', name: 'star', imagePath: 'star.png' }, { group: 'admin_tasks', name: 'interview designer', label: 'interview designer' }, { group: 'admin_tasks', name: 'interviewer', label: 'interviewer' }, { group: 'admin_tasks', name: 'datas analysis', label: 'datas analysis' }, { group: 'exp_tags', name: 'highly experienced interviewer', label: 'highly experienced interviewer' }, { group: 'exp_tags', name: 'highly experienced interviewee', label: 'highly experienced interviewee' } ] ```
chethan-K commented 2015-04-28 13:16:02 +00:00 (Migrated from github.com)

Hi

Does sheet_to_row_object_array ensures the running order of excel sheet rows...?

Thanks in advance

Hi Does sheet_to_row_object_array ensures the running order of excel sheet rows...? Thanks in advance
SheetJSDev commented 2015-04-28 14:59:24 +00:00 (Migrated from github.com)

@chethan-K I think you are asking if the rows are in the same order that they appear in the excel sheet, and the answer is yes (it walks row-by-row in order when generating the output)

@chethan-K I think you are asking if the rows are in the same order that they appear in the excel sheet, and the answer is yes (it walks row-by-row in order when generating the output)
chethan-K commented 2015-04-29 09:20:12 +00:00 (Migrated from github.com)

@SheetJSDev Yes, I was looking for the same thing. Thanks :)

@SheetJSDev Yes, I was looking for the same thing. 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#4
No description provided.