16,718
社区成员
发帖
与我相关
我的任务
分享
Public Class Form1
Dim connString As String = "provider=Microsoft.Jet.OLEDB.4.0;data source=tmp.xls;Extended Properties=Excel 8.0;"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using connection As New OleDbConnection(connString)
Dim command As New OleDbCommand("select * from [Sheet1$]", connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
Dim G As Graphics
G = Me.CreateGraphics()
While reader.Read
G.DrawLine(Pens.Black, CSng(reader(0)), CSng(reader(1)), CSng(reader(2)), CSng(reader(3)))
'测试数据
' G.DrawLine(Pens.Black, 10, 10, 100, 290)
' G.DrawLine(Pens.Red, 250, 10, 105, 290)
'G.DrawLine(Pens.LightGreen, 0, 210, 300, 80)
End While
End Using
End SubImports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim connString As String = "provider=Microsoft.Jet.OLEDB.4.0;data source=worklog.xls;Extended Properties=Excel 8.0;"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using connection As New OleDbConnection(connString)
Dim command As New OleDbCommand("select * from [Sheet1$]", connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
Dim G As Graphics
G = Me.CreateGraphics()
While reader.Read()
G.DrawLine(Pens.Black, reader(0), reader(1), reader(2), reader(3))
End While
' Call Close when done reading.
reader.Close()
End Using
End Sub