用excel数据填充Javascript数组

好吧,我是新来的javascript (尽快学习)。 我已经能够凑齐一些代码做一些事情。

  1. 打开/读取一个Excel文件(本地现在,但将在服务器上)。 获取单元格A1 (将始终是一个# ) – variablesrepCount。
  2. 将单元格A2-A33写入html表格(硬编码启动和停止)

现在我要做的是

  1. 将repCountvariables作为书写部分的结束行 – dynamic停止点
  2. 把它写到我可以操作的数组(应该是全局可用的)。

这是我的代码到目前为止:

  <script language="javascript" > // 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<=numRows; rowIndex++) { curRow = document.createElement('tr'); for (colIndex=1; colIndex<=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(); } </script> </head> <body> <p>&nbsp;</p> <div style="background: #009955; width:'100%';" align="center"> <font color="#000080" size="12pt"> <b>Get data from excel sheets</b> </font> </div> <center> <p>&nbsp;</p> <div id="div1" style="background: #DFDFFF; width:'100%';" align="center"> To start the statistics page - Click the button below </div> <input type="button" value="Start" onClick="GetData(1,1);" /> <input type="button" value="Next" onClick="myOnLoad2()" /> </center> <b>Get data from excel sheets</b> <table id='dataTable'> <tbody id='dataTableBody'> </tbody> </table> </body> </html> 

我在正确的轨道上? 我只能使用JavaScript,所以不要试图将我指向jQuery或PHP。 任何人都可以帮助或指点我一个很好的资源,我想学习这个,但语法和我…不是这样的好朋友。 一旦我看到一个例子,我很好的弄清楚如何适应它,但是把它放到一个数组中让我在上个星期感到惊讶。 提前致谢。