1

我有以下代码用于在javascript中读取 excel :

<html>
<head>
<script type="text/javascript">
function readData(x,y)
{

      var excel = new ActiveXObject("Excel.Application");

      alert(excel);

      var excel_file = excel.Workbooks.Open("D:\File1.xlsx");
      Excel.Visible = true;

      alert(excel_file);

      var excel_sheet = excel_file.Worksheets("DEPT INC UPDATE");

      alert(excel_sheet);

      var data = excel_sheet.Cells(x,y).Value;

      alert(data);

      return data;


}



</script>
</head>
<body>

<input type="button" value="SimpleButton" onclick="readData(2,3);" />
</body>
</html>

但是不知道哪里出错了??

4

2 回答 2

1

您的输入元素是一个提交按钮,但不在表单内。当 readData 返回数据时,没有任何东西可以使用它。至于其余的,我不知道。你不说哪里出了问题。它是否显示任何一个警报框?

于 2011-08-04T09:42:20.760 回答
0

i think there is an error in giving the path. Use double backward slashes instead of single.

In your case..

D:\File1.xlsx

Hope this might be helpful..:)

于 2013-05-20T15:27:58.077 回答