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瀏覽器。 –