最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Reading Excel file from JavaScript - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question edited Aug 7, 2014 at 14:17 Pratik asked Aug 4, 2011 at 9:37 PratikPratik 11.8k22 gold badges70 silver badges99 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 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?

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)

  1. 暂无评论