Reading Excel file from JavaScript

自古美人都是妖i 提交于 2019-12-06 16:08:53

问题


I have following code for reading excel in javascript :

<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>

But dunno where it is going wrong ??


回答1:


your input element is a submit button, but is not inside a form. When readData returns the data, nothing ever makes any use of it. and as to the rest, i dunno. you don't say where it's going wrong. does it show any one alert box?




回答2:


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..:)



来源:https://stackoverflow.com/questions/6939135/reading-excel-file-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!