ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 读EXCEL写文件简例

读EXCEL写文件简例

原创 Linux操作系统 作者:kirinri 时间:2008-01-10 20:26:22 0 删除 编辑

[code]

Module

Module1Sub Main()Dim strCon As String

Dim strCom As String

Dim myConn As System.Data.OleDb.OleDbConnectionDim myCommand As System.Data.OleDb.OleDbDataAdapterDim myDataSet As DataSetDim strVa As String

Dim exM As String

Try

strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = E: tt.xls; Extended Properties=Excel 8.0"

myConn =

strCom = " SELECT * FROM [Sheet1$]"

myConn.Open()

myCommand =

myDataSet =

myCommand.Fill(myDataSet, "TableSheet1")

exM = ex.Message()

myConn.Close()

System.Console.Write("Catch exception")

New System.Data.OleDb.OleDbConnection(strCon)New System.Data.OleDb.OleDbDataAdapter(strCom, myConn)New DataSetCatch ex As ExceptionEnd Try

myConn.Close()

'get Value

strVa = myDataSet.Tables(0).Rows(0)(2)

Dim tw As System.IO.StreamWriterTry

tw =

tw.WriteLine(strVa)

Dim stP As String = "E: .txt"New System.IO.StreamWriter(stP)Catch

tw.Close()

System.Console.Write("Catch exception")

End Try

tw.Close()

End

End Sub Module

[/code]

发表于:2007.08.07 14:02

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12476590/viewspace-134137/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-21

  • 博文量
    257
  • 访问量
    495392