-1

I am using electron for developing an application in which I need to open a local excel file on button click

<html>
      <script type="text/javascript">
      function test() {
      var Excel = new ActiveXObject("Excel.Application");
      Excel.Visible = true;
      Excel.Workbooks.Open("C:/Users/Lenovo/.electron/test.xlsx");
     }
     </script>

     <body>

         <form name="form1">
         <input type=button onClick="test();" value="Open File">
         <br><br>
         </form>

     </body>
</html>

The button click in this code does not work in electron.

K.U.
  • 17
  • 3
  • Please add more details to you question. – AsthaUndefined Feb 25 '19 at 05:24
  • Welcome to Stack Overflow! The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific problem you're having in a [Minimal, Complete, and Verifiable](https://stackoverflow.com/help/mcve) example. For more information, please see [How to Ask](https://stackoverflow.com/questions/how-to-ask) and take the [tour](https://stackoverflow.com/tour). – acobster Feb 25 '19 at 05:24
  • You should look at http://oss.sheetjs.com/ – Mayank Vadiya Feb 25 '19 at 06:24

1 Answers1

1

Just add this code in html page and use electron message communication to execute this

<form name="form1">
  <input type=button onClick="test()" value="Open File">
</form>



 <script type="text/javascript">
      function test() {
        var Excel = new ActiveXObject("Excel.Application");
        Excel.Visible = true;
        Excel.Workbooks.Open("teste.xlsx");
      }
    </script>
Karan Shah
  • 111
  • 11
Mayur
  • 4,345
  • 3
  • 26
  • 40
  • What happened when you did that ? Please elaborate with code or error. – Mayur Feb 25 '19 at 06:03
  • You need to add proper path to the file in the code, if it won't find the mentioned file it will create new blank excel sheet. If it doesn't work, In next reply show us your full code that you are running. – Mayur Feb 25 '19 at 06:23
  • The button click does not open any excel sheet in "electron". – K.U. Feb 25 '19 at 06:24
  • @K.U. Code? and stop deleting your comments. – Mayur Feb 25 '19 at 06:25


  • – K.U. Feb 25 '19 at 06:28
  • ActiveXObject() method is for only Internet Explorer only. so may be this stuck inside your electron as it is use chrome as browser. – Mayur Feb 25 '19 at 07:08
  • So is there any solution available for this problem in electron – K.U. Feb 25 '19 at 09:28
  • Follow this link https://stackoverflow.com/a/28862951/6541218 this might be help. – Mayur Feb 25 '19 at 09:32