如何创建一个PDF文件?
<%
option explicit
sub checkxldriver()
on error resume next
dim vconnstring
dim oconn, oerr
vconnstring = "driver={microsoft excel driver (*.xls)};dbq=nul:"
' 连接nul.
set oconn = createobject("adodb.connection")
oconn.open vconnstring
for each oerr in oconn.errors
' 如果excel程序报告"文件创建失败",别担心,这表示它正在正常运行呢.
if oerr.nativeerror = -5036 then
exit sub
end if
next
response.write " mdac 供应商或驱动程序不可用,请检查或重新安装!<br><br>"
response.write hex(err.number) & " " & err.description & "<br>"
for each oerr in oconn.errors
response.write hex(oerr.number) & " " & oerr.nativeerror & " " &
oerr.description & "<br>"
next
response.end
end sub
function getconnection(vconnstring)
on error resume next
set getconnection = server.createobject("adodb.connection")
getconnection.open vconnstring
if err.number <> 0 then
set getconnection = nothing
end if
end function
function optiontag(vchoice,vtrue)
dim vselected
if vtrue then
vselected = "selected"
end if
optiontag = "<option " & vselected & ">" & _
server.htmlencode(vchoice) & "</option>" & vbcrlf
end function
function ischecked(vtrue)
if vtrue then
ischecked = "checked"
end if
end function
function bookoptions(vxlfile)
dim vserverfolder
dim ofs, ofolder, ofile
dim vselected
vserverfolder = server.mappath(".")
set ofs = server.createobject("scripting.filesystemobject")
set ofolder = ofs.getfolder(vserverfolder)
for each ofile in ofolder.files
if ofile.type = "microsoft excel worksheet" then
vselected = (ofile.name = vxlfile)
bookoptions = bookoptions & _
optiontag(ofile.name, vselected)
end if
next
set ofolder = nothing
set ofs = nothing
end function
function namedrangeoptions(oconn, vxlrange, vtabletype)
dim oschemars
dim vselected
namedrangeoptions = optiontag(empty, empty)
if typename(oconn) = "connection" then
set oschemars = oconn.openschema(adschematables)
do while not oschemars.eof
if oschemars("table_type") = vtabletype then
vselected = (oschemars("table_name") = vxlrange)
namedrangeoptions = namedrangeoptions & _
optiontag(oschemars("table_name"), vselected)
end if
oschemars.movenext
loop
end if
end function
function datatable(oconn, vxlrange, vxlhasheadings)
on error resume next
const db_e_errorsincommand = &h80040e14
dim ors, ofield
dim vthtag, vthendtag
if vxlhasheadings then
vthtag = "<th>"
vthendtag = "</th>"
else
vthtag = "<td>"
vthendtag = "</td>"
end if
datatable = "<table border=1>"
if typename(oconn) = "connection" then
set ors = oconn.execute("[" & vxlrange & "]")
if oconn.errors.count > 0 then
for each oconnerr in oconn.errors
if oconnerr.number = db_e_errorsincommand then
datatable = datatable & _
"<tr><td>该范围不存在:</td><th>" & vxlrange & "</th></tr>"
else
datatable = datatable & _
"<tr><td>" & oconnerr.description & "</td></tr>"
end if
next
else
datatable = datatable & "<tr>"
for each ofield in ors.fields
datatable = datatable & vthtag & ofield.name & vthendtag
next
datatable = datatable & "</tr>"
do while not ors.eof
datatable = datatable & "<tr>"
for each ofield in ors.fields
datatable = datatable & "<td>" & ofield.value & "</td>"
next
datatable = datatable & "</tr>"
ors.movenext
loop
end if
[1] [2] 下一页
下一篇: 使用dapper遇到的问题及解决方法