I have read though several post and have not yet found anything that seems to be exactly what I am looking for. I want to read several rows out of an excel file and based on the contents of the first row place the remaining columns into an array. I was trying to do this with excel or just a CSV (OLE and DDT) but without much luck. The DDT does not seem to be the way to go and Excel is giving me an error.

Basically when I am going to look at the first cell to read its value and decide (using a switch statement) what array to put it it, the script fails. So it will open the file, and throw the error seen below at line 23 which is the switch. I have gone through and put a string value in and it will drop into the appropriate case. But then fail on the assign so I believe it has something to do with how I am selecting the data form the cell. I used Working With Excel Files via COM as my example to work from.


var Uarray = [];

var SEarray = [];

var Carray = [];

for(var i = 0; i < 6; i++) {

switch(VarToStr(Excel.Cells(i,0))) //This is line 23
// I have tried Excel.ActiveSheet.Cell


case "E":

for(var j=0; j < 13; j++) {

Earray[j] = VarToStr(Excel.Cells(i, j));




case "U":

for(var k=0; k < 13; k++) {

Uarray[k] = VarToStr(Excel.Cells(i, k));




case "C":

for(var l=0; l < 13; l++) {

Carray[l] = VarToStr(Excel.cells(i, l));




Log.Message("Value found that was not expected");




Error: Microsoft JScript runtime error
Expected ';'
Error Location: Line 23 Col 5