开发者

Reading Excel file from JavaScript

开发者 https://www.devze.com 2023-03-25 00:10 出处:网络
I have following code for reading excel in javascript : <html> <head> <script type=\"t开发者_StackOverflow社区ext/javascript\">

I have following code for reading excel in javascript :

<html>
<head>
<script type="t开发者_StackOverflow社区ext/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 ??


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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消