如何接受来自HTML的数据并将其发送到Excel?

以下是我的代码。 问题是它不是将这些字段添加到Excel工作表。

<! DOCTYPE html> <Html> <Head> <script language="vbscript" type="text/vbscript"> Sub Sample () Dim iRow Set objExcel = CreateObject ("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open ("C:\Users\ARPIT SHAJU\Desktop\Church\Member.xlsx") objExcel.Application.Visible = True ObjWorkbook.Windows (1).Visible = True Set XlSheet =objWorkbook.Sheets (1) XlSheet.Activate iRow = 1 With objExcel Do while .Cells (iRow, 1).value <> "" .Cells (iRow, 1).activate iRow = iRow + 1 Loop .Cells (iRow, 1).value=Document.GetElementsByName ("fname") (0).Value .Cells (iRow, 2).value=Document.GetElementsByName ("surname") (0).Value .Cells (iRow, 3).value=Document.GetElementsByName ("gender") (0).Value .Cells (iRow, 4).value=Document.GetElementsByName ("mstatus") (0).Value .Cells (iRow, 5).value=Document.GetElementsByName ("dob") (0).Value .Cells (iRow, 6).value=Document.GetElementsByName ("doa") (0).Value .Cells (iRow, 7).value=Document.GetElementsByName ("baptised") (0).Value .Cells (iRow, 8).value=Document.GetElementsByName ("residence") (0).Value .Cells (iRow, 9).value=Document.GetElementsByName ("mnumber") (0).Value MsgBox "Data Added Successfully”, vbinformation Document.GetElementsByName ("fname") (0).Value="" Document.GetElementsByName ("surname") (0).Value="" Document.GetElementsByName ("gender") (0).Value="" Document.GetElementsByName ("mstatus") (0).Value="" Document.GetElementsByName ("dob") (0).Value="" Document.GetElementsByName ("doa") (0).Value="" Document.GetElementsByName ("baptised") (0).Value="" Document.GetElementsByName ("residence") (0).Value="" Document.GetElementsByName ("mnumber") (0).Value="" End With ObjWorkbook. Save ObjWorkbook. Close Set objWorkbook = Nothing Set objExcel = Nothing End Sub </script> <style type="text/css"> fieldset { border: #00cc00 2px solid; padding: 10px; color: green; </style> <body <form> <fieldset> <legend>Csharpcorner</legend> <center> First name:<br> <input type="text" name="fname" Value=""><br> Surname:<br> <input type="text" name="surname" Value=""><br> Gender :<br> <input type="text" name="gender" Value=""><br> Marital Status :<br> <input type="text" name="mstatus" Value=""><br> Date of Birth :<br> <input type="text" name="dob" Value=""><br> <br> Marriage Date :<br> <input type="text" name="doa" Value=""><br> Baptised :<br> <input type="text" name="baptised" Value=""><br> Residence :<br> <input type="text" name="residence" Value=""><br> Mobile Number :<br> <input type="text" name="mnumber" Value=""><br> <input type="button" onclick="Sample()" value="Submit"><br> </center> </fieldset> <form> </body> </html> 

我有我的Excel和记事本在同一个文件夹。 代码有什么问题? 我怎样才能把它添加到工作表的值? 我想在没有任何数据库或服务器的情况下使用它。 这是用于人员目的的离线forms。 欢迎任何更好的解决scheme。

从网站复制代码时需要小心。 你需要用双引号replace所有的引号"


代码段图片