把EXCEL的数据作为点导入pictruebox直角坐标系

ym1622 2008-04-07 08:08:35
例如EXCLE数据为
A B C D E
1 11 10 8 5 4
2 5 8 5 6 4
3 45 6 6 65 5
怎么样在pictruebox直角坐标系以多点多条线的形式画出来?给个代码
效果和下图差不多(下图和上面的数据不一致哈)
谢谢各位了
...全文
106 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vlsm 2008-04-08
  • 打赏
  • 举报
回复
加上CSng,测试数据如注释里面
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 Sub
ym1622 2008-04-08
  • 打赏
  • 举报
回复
LS的没法运行
ym1622 2008-04-08
  • 打赏
  • 举报
回复
上面的方法不行啊
郁闷``有哪位再说下?
vlsm 2008-04-07
  • 打赏
  • 举报
回复


Imports 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

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧