0
我有一个html表单,我想将表单数据存储到Excel表单中。我正在使用Linux(Fedora 15)操作系统。我有一个VB脚本,适用于Internet Explorer,Windows操作系统。但相同的脚本不能在Linux Mozilla Firefox浏览器中工作。请告诉我用于将我的html数据存储到Excel表格中的java脚本,该脚本适用于Linux操作系统和Mozilla Firefox浏览器。我分享我的VB脚本,请告诉我更正,所以我可以使用它作为Java脚本。如何使用java脚本将html表单保存为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("home/Book1.xlsx")
'Document.GetElementsByName("fname")(0).Value="C#"
'Document.GetElementsByName("lname")(0).Value="Corner"
'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
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("lname")(0).Value
.Cells(iRow, 3).value=Document.GetElementsByName("Add1")(0).Value
.Cells(iRow, 4).value=Document.GetElementsByName("Add2")(0).Value
MsgBox "Data Added Sucessfully",vbinformation
Document.GetElementsByName("fname")(0).Value=""
Document.GetElementsByName("lname")(0).Value=""
Document.GetElementsByName("Add1")(0).Value=""
Document.GetElementsByName("Add2")(0).Value=""
End With
objWorkbook.save
objWorkbook.close
Set objWorkbook = Nothing
Set objExcel = Nothing
End Sub
</script>
<body>
<form>
<fieldset>
<center>
First name:<br>
<input type="text" name="fname" Value=""><br>
Last name:<br>
<input type="text" name="lname" Value=""><br>
Address1:<br>
<input type="text" name="Add1" Value=""><br>
Address2 :<br>
<input type="text" name="Add2" Value=""><br>
<br>
<input type="button" onclick="Sample()" value="Submit" /><br>
</center>
</fieldset>
</form>
</body>
</html>
对于这个代码,我的每一次点击在我的Excel工作表提交按钮创建一个行和存储数据创建Excel工作表在我的电脑。
SO不是免费的翻译服务。请自己尝试翻译,并在有关*特定*问题的问题时回来。 –
我想将html表单存储到excel工作表中。我有这个VB脚本,这工作正常,但我想这个Java脚本,因为VB脚本只支持在Internet Explorer浏览器。 –