窗体里添加webBrowser1 (在部件里添加Microsoft internet control)和 Command1控件。 运用以下的函数将 Adodc1.Recordset 返回到HTML表格中,为什么实现不了啊?哪位高手支支招???
Private Sub Command1_Click()
Dim strHtml As String
strHtml = "<html>" & vbCrLf
strHtml = strHtml & "<head>" & vbCrLf
strHtml = strHtml & "</head>" & vbCrLf
strHtml = strHtml & "<h1 align='center'>报告单</h1>" & vbCrLf
strHtml = strHtml & "<body>" & vbCrLf
strHtml = strHtml & ReturnHTMLTable(Adodc1)
strHtml = strHtml & "<li>" & vbCrLf
strHtml = strHtml & "Hello" & vbCrLf
strHtml = strHtml & "<input type='button' name='Submit22' value=' 打印此页 ' onClick='javascript:print();'>" & vbCrLf
strHtml = strHtml & "</li>" & vbCrLf
strHtml = strHtml & "</body>" & vbCrLf
strHtml = strHtml & "</html>" & vbCrLf
WebBrowser1.Document.body.innerHTML = strHtml
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 "about:blank"
End Sub
-----------------------------------------------------------------------
Function ReturnHTMLTable(tmpAdodc)
Set rs = tmpAdodc.Recordset
rs.MoveFirst
response.Write "<table class=""data"" cols=""" & rs.Fields.Count & """>"
response.Write "<tr>"
For Each oField In rs.Fields
response.Write "<th>" & oField.Name & "</th>"
Next
response.Write "</tr>"
Do While Not rs.EOF
response.Write "<tr>"
For Each oField In rs.Fields
response.Write "<td>"
If IsNull(oField) Then
response.Write " "
Else
response.Write oField.Value
End If
response.Write "</td>"
Next
rs.MoveNext
response.Write "</tr>"
Loop
response.Write "</table>"
End Function
不要添加html,head,body这种标签试试,你是设置body容器
' strHtml = "<html>" & vbCrLf
' strHtml = strHtml & "<head>" & vbCrLf
'strHtml = strHtml & "</head>" & vbCrLf
strHtml = strHtml & "<h1 align='center'>报告单</h1>" & vbCrLf
'strHtml = strHtml & "<body>" & vbCrLf
strHtml = strHtml & ReturnHTMLTable(Adodc1)
strHtml = strHtml & "<ul><li>" & vbCrLf
strHtml = strHtml & "Hello" & vbCrLf
strHtml = strHtml & "<input type='button' name='Submit22' value=' 打印此页 ' onClick='javascript:print();'>" & vbCrLf
strHtml = strHtml & "</li></ul>" & vbCrLf
' strHtml = strHtml & "</body>" & vbCrLf
' strHtml = strHtml & "</html>" & vbCrLf
WebBrowser1.Document.body.innerHTML = strHtml
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。