1

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

0

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

1 Comment

then it looks like the line Excel.Visible = true; could be the culprit. Since, it never get to the alert right after that. mind that JavaScript is case sensitive. If you intended to say excel.Visible = true; then just change the upper-case E to e
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..:)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.