如何使用javascript和HTML打开数据并将其附加到excel

问题描述 投票:0回答:1

我想知道如何使用JavaScript将html输入数据附加到Excel中。

我已经编写了使用ActiveXObject使用JavaScript创建excel的代码,请参见下面的示例编写代码:

<head>
  <script language="javascript">
    function WriteToFile(passForm) {
       var ExcelApp = new ActiveXObject("Excel.Application");
       var ExcelSheet = new ActiveXObject("Excel.Sheet");
       ExcelSheet.ActiveSheet.Cells(1,1).Value = passForm.FirstName.value;
       ExcelSheet.ActiveSheet.Cells(1,2).Value = passForm.LastName.value;
       ExcelSheet.SaveAs("D:\\TEST.xlsx");
       ExcelSheet.Application.Quit();
    }
 </script>
</head>
<body">
  <p>create a excel file with following details -</p>
<form>
   Type your first name: <input type="text" name="FirstName" size="20">
   Type your last name: <input type="text" name="LastName" size="20">
   <input type="button" value="submit" onclick="WriteToFile(this.form)">
</form>
</body>
</html>

我们需要完成的任务:

  1. 如果不存在则打开现有的excel,然后创建新的excel并打开
  2. 从HTML格式将数据填充到excel中

以上所有任务都需要借助JavaScript来完成。

javascript html excel wsh
1个回答
0
投票

您找到任何解决方案了吗?我需要使用javascript进行相同的过程,但没有找到解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.