imports Microsoft.VisualBasic
Public Class Class1
Public Shared Function GetAllSheetname(ByVal strfilePath As String) As String()
Dim strConn As String = String.Empty
If strfilePath.EndsWith("xls") Then
strConn = "ProvIDer=Microsoft.Jet.olEDB.4.0; " + _
"Data Source=" + strfilePath + "; " + _
"Extended PropertIEs='Excel 8.0;IMEX=1'"
ElseIf strfilePath.EndsWith("xlsx") Then
strConn = "ProvIDer=Microsoft.ACE.olEDB.12.0;" + _
"Data Source=" + strfilePath + ";" + _
"Extended PropertIEs='Excel 12.0;HDR=YES'"
End If
Dim conn As oleDbConnection = New oleDbConnection(strConn)
conn.open()
Dim sheetnames(conn.GetSchema("tables").Rows.Count - 1) As String For i As Integer = 0 To conn.GetSchema("tables").Rows.Count - 1 sheetnames(i) = conn.GetSchema("tables").Rows(i)("table_name").ToString Next conn.Close() Return sheetnames End Function End Class
总结以上是内存溢出为你收集整理的vb.net取得Excel中的全部sheet名称(亲自实践)全部内容,希望文章能够帮你解决vb.net取得Excel中的全部sheet名称(亲自实践)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)