将数据从HTML存储到Excel [英] Storing data from HTML to Excel
问题描述
嗨朋友们,
当我点击提交按钮时我有html表格.data应该移到excel表格
再次,如果我再输入一个html格式的数据,应该附加在excel中而不是替换!!
下面是我的html文件。 ..请帮助我。
我在VBScript中没有想法。请
< HTML>
< HEAD>
< TITLE>导出到Excel< / TITLE>
< / HEAD>
< SCRIPT语言=VBScript>
功能导出(P,R)< br $>
设置ExcelApp = CreateObject(Excel.application)
ExcelApp.Visible = True
strPathDoc =D:\atul.xls'您的文件路径
设置myExcelDoc = ExcelApp.Workbooks.Open(strPathDoc)
ExcelApp.Visible = True
myExcelDoc.Windows(1).Visible = True
set XlSheet = myExcelDoc.Worksheets(2)
XlSheet.Range(A6)。value = P
XlSheet.Range(A7)。value = R
myExcelDoc.save
myExcelDoc.close
设置myExcelDoc = Nothing
设置ExcelApp = Nothing
结束功能
Sub cmdExp_OnClick()
Dim lPrincipal
Dim dblRate
Frstnm = Disnm .value
Lstnm = TreatGrp.value
cInterest = Export(Frstnm,Lstnm)
End Sub < br / >
< / SCRIPT> < BODY>
名字:< INPUT Type =TextName =DisnmValue =>
姓:< INPUT Type =TextName =TreatGrpValue =>
< INPUT Type =Button
Name =cmdExpValue =Connect> < / BODY> < / HTML>
Hi Friends,
I have html form when I click submit button .data should be moved to a excel sheet
Again if I entered one more data in html form that should be appended in excel not replace !!
below is the my html file in ...please help me out.
I dont have idea in VBScript. please
<HTML>
<HEAD>
<TITLE>Exporting into Excel</TITLE>
</HEAD>
<SCRIPT Language = "VBScript">
Function Export(P,R)
Set ExcelApp = CreateObject("Excel.application")
ExcelApp.Visible = True
strPathDoc = "D:\atul.xls" 'Your File path
Set myExcelDoc = ExcelApp.Workbooks.Open(strPathDoc)
ExcelApp.Visible = True
myExcelDoc.Windows(1).Visible = True
set XlSheet = myExcelDoc.Worksheets(2)
XlSheet.Range("A6").value=P
XlSheet.Range("A7").value=R
myExcelDoc.save
myExcelDoc.close
Set myExcelDoc = Nothing
Set ExcelApp = Nothing
End Function
Sub cmdExp_OnClick()
Dim lPrincipal
Dim dblRate
Frstnm = Disnm.value
Lstnm = TreatGrp.value
cInterest = Export(Frstnm, Lstnm)
End Sub
< /SCRIPT> <BODY>
First Name: <INPUT Type="Text" Name="Disnm" Value="">
Last Name : <INPUT Type="Text" Name="TreatGrp" Value="">
<INPUT Type="Button"
Name="cmdExp" Value="Connect"> </BODY> </HTML>
推荐答案
将值分配到单元格时,应检查这些单元格是否具有值。
例如,如果你想垂直追加值:A6,A7,然后是A8,A9,第3次是A10,11,
你可以使用这个:
When you assign your values into cells, you should check if these cells have values or not.
For example, if you want to append values vertically: A6, A7, then A8, A9, and the 3rd time is A10, 11,
you can use this:
currentRow = 6
currentVal = XlSheet.Range("A" & currentRow).value
While currentVal <> ""
currentRow = currentRow + 1
currentVal = XlSheet.Range("A" & currentRow).value
Wend
XlSheet.Range("A" & currentRow).value = P
XlSheet.Range("A" & (currentRow + 1)).value = R
这篇关于将数据从HTML存储到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!