[求助]请教!怎么样才能实现如下效果呢
EXCEL中有坐标表,怎么样才能实现如下效果呢:根据表中的坐标值直接绘出直线?急——在线等待 没人来? 把单元格中数据附给定义的VARIANT变量,然后用ADDLINE方法就可以了。 别人写的一段程序,看看
Sub ADO_EXCEL_TEST()
On Error Resume Next
Dim adoConnection As New ADODB.Connection
Dim adoRecordset As New ADODB.Recordset
Dim SPoint(0 To 2) As Double
Dim EPoint(0 To 2) As Double
Dim i As Integer
adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=d:\book2.xls;Extended Properties='Excel 8.0;HDR=No'"
'Microsoft.Jet.OLEDB.4.0 方式,(建议)
' HDR=No HDR参数设置是否强制将第一行单元格作为字段名称 YESà将第一行单元格作为字段名称;NOà忽略
adoRecordset.Open "select * from ", adoConnection, adOpenKeyset, adLockOptimistic '读取SHEET1的数据
For i = 0 To 2
SPoint(i) = adoRecordset.Fields(i).Value
Next
adoRecordset.MoveNext
For i = 0 To 2
EPoint(i) = adoRecordset.Fields(i).Value
Next
ThisDrawing.ModelSpace.AddLine SPoint, EPoint
End Sub 上面的代码最后应该有
adoRecordset.close
set adoRecordset=nothing
adoConnection.close
set adoConnection=nothing
否则内存很有可能不会被释放 都不可以呀,对不起,可不可以写的详细点呀。 我试过了。
保证 d:\book2.xls
book2.xls的SHEET1 中有要的两个点的坐标。
For i = 0 To 2
SPoint(i) = adoRecordset.Fields(i).value
Next
adoRecordset.MoveNext
For i = 0 To 2
EPoint(i) = adoRecordset.Fields(i).value
Next
是分别读取X,Y,Z值。
页:
[1]