title: Populate Javascript array with excel data
body: <p>Ok, I'm new to <code>javascript</code> (learning quickly though).  I've been able to cobble together some code which does a couple of things.</p>
  
  <ol>
  <li>Opens/reads an excel file (local now but will be on server).  Get
  cell <code>A1</code> (will always be a <code>#</code>) - variable repCount. </li>
  <li>Writes cells <code>A2-A33</code> to a table in html (hard coded start and stop)</li>
  </ol>
  
  <p>Now what I would it to do is</p>
  
  <ol>
  <li>take the repCount variable as the ending row in the writing part - dynamic stop point</li>
  <li>write it to an array that I can manipulate (should be globally available).</li>
  </ol>
  
  <p>Here's my code so far: </p>
  
  <pre><code> &lt;script language="javascript" &gt;
   // Open the spreadsheet and get the count of reps
   function GetData(cell,row)
       {
      var excel = new ActiveXObject("Excel.Application");
      var excel_file = excel.Workbooks.Open("SOMEFILE.xlsx");
      var excel_sheet = excel.Worksheets("Sheet1");
      var repCount = excel_sheet.Cells(cell,row).Value;
      document.getElementById('div1').innerText = repCount; 
      }
  
   //   open spreadsheet and populate table with representatives
       var excelApp=null, excelFile=null, excelSheet=null;
       var filename = "SOMEFILE.xlsx";
  
   function initExcel(filename)
        {
        excelApp = new ActiveXObject("Excel.Application");
        excelFile = excelApp.Workbooks.Open(filename);
        excelSheet = excelApp.Worksheets('Sheet1');
        }
  
   function myShutdownExcel()
        {
        excelApp.Quit();
        excelApp=null;
        excelFile=null;
        excelSheet=null;
        }
  
   function myGetData(column, row)
        {
        return excelSheet.Cells(column, row).Value;
        }
  
   function byId(e) {return document.getElementById(e);}
  
   function myOnLoad2()
        {
        var numRows = 33, numCols = 1;
        var tBody = byId('dataTableBody');
        var rowIndex, colIndex, curVal;
        var curRow, curCell, curCellText;
        initExcel(filename);
  
       for (rowIndex=2; rowIndex&lt;=numRows; rowIndex++)
        {
        curRow = document.createElement('tr');
        for (colIndex=1; colIndex&lt;=numCols; colIndex++)
        {
        curVal = myGetData(rowIndex, colIndex);
        curCell = document.createElement('td');
        curCell.setAttribute('title', 'The value of cell [' + rowIndex + ',' + colIndex +']\nis: ' + curVal);
        curCellText = document.createTextNode(curVal);
        curCell.appendChild(curCellText);
        curRow.appendChild(curCell);
        }
        tBody.appendChild(curRow);
        }
        myShutdownExcel();
        }
  
      &lt;/script&gt;
   &lt;/head&gt;
    &lt;body&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
        &lt;div style="background: #009955; width:'100%';" align="center"&gt;
          &lt;font color="#000080" size="12pt"&gt;
        &lt;b&gt;Get data from excel sheets&lt;/b&gt;
          &lt;/font&gt;
        &lt;/div&gt;
        &lt;center&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
        &lt;div id="div1" style="background: #DFDFFF; width:'100%';" align="center"&gt;
        To start the statistics page - Click the button below
        &lt;/div&gt;
  
    &lt;input type="button" value="Start" onClick="GetData(1,1);" /&gt;
    &lt;input type="button" value="Next" onClick="myOnLoad2()" /&gt;
    &lt;/center&gt;
     &lt;b&gt;Get data from excel sheets&lt;/b&gt;
    &lt;table id='dataTable'&gt;
    &lt;tbody id='dataTableBody'&gt;
    &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>Am I on the right track?  I can only use javascript so don't try pointing me to jQuery or PHP.  Can anyone help or point me to a good resource, I do want to learn this but syntax and me...not such good friends.  Once I see an example I'm pretty good about figuring out how to adapt it but getting it into an array has boggled me for the last week.  Thanks in advance.</p>