时间:2021-05-18
<%
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]下一页
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
还有一个用于创建PDF文件的项目----iText。PDFBox下面有两个子项目:FontBox是一个处理PDF字体的java类库;JempBox是一个处理XM
方法一:文件导出为PDF格式 第一步:在文档编辑完成后,选择【文件】-【导出】命令。在右侧选择“创建PDF/XPS文档”选项,然后点击“创建PDF/XPS文档
PDF如何添加打印注释,PDF添加打印注释的方法是什么呢?下面我们来看看如何给PDF文件添加一个打印机注释。软件名称:迅捷PDF编辑器v2.1.0.0官方最新安
pdf如何转换成word?这是很多网友都在咨询的一个问题,大家在工作生活中经常需要将无法编辑的PDF文件转换成可以编辑的word文件,这样就可以对PDF文件
有的浏览器安装了pdf打开程序关联到浏览器,所以直接写上pdf路径时是打开pdf而不是下载,下面我就说下如果让他们只是下载,而不是浏览。创建一个php文件复制代