我想知道如何使用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>
我们需要完成的任务:
以上所有任务都需要借助JavaScript来完成。
您找到任何解决方案了吗?我需要使用javascript进行相同的过程,但没有找到解决方案。