Sub excell()
; t8 }+ m! V3 @4 D3 Y/ CDim x, y As Variant- d8 H+ [- d! z
Dim Excel As Excel.Application
* _# C/ N2 r% x( S cDim ExcelSheet As Object @. ^ x( w; [& ^$ a4 M) L
Dim ExcelWorkbook As Object
! G. K' \" f3 u' Y" \; tSet ExcelWorkbook = Excel.Workbooks.Open("d:\基础数据.xls") '
3 p+ n* d2 f8 P3 C& W4 h& P0 \+ aSet ExcelWorkbook.Visible = True6 m+ H- M1 R' Q2 c- [- u6 R
Set ExcelSheet = ExcelWorkbook.Worksheets("基础数据") ') L4 B n! {$ X* e R( O3 o
ExcelSheet.Activate '/ e& O) u; Q1 T2 S: W
x(0) = 0: x(1) = 0: x(2) = 0
, i4 D& O4 U" G& m3 \# b, kFor i = 1 To 501 U0 U7 R( A3 m" H: W
y(0) = ExcelSheet.cells(i, 1).Value
! _' j3 ]$ w: Q7 q* j/ r* X y(1) = ExcelSheet.cells(i, 2).Value- F. M$ {; `$ h5 }8 p7 E4 _) A
y(2) = 08 p* ?9 r) N% F M6 e
Call ThisDrawing.ModelSpace.AddLine(x(i), y(i))! Y/ q, A8 L# [8 ]" F5 m( m6 b4 Y
y = x& u# ?5 U: v9 U0 s1 L6 m7 K
Next2 \- d" |; x1 K# e; Y
End Sub2 @5 o# O9 s/ h2 v: l- {
……………………………………………………………………5 l, K4 [* L) t& `! N! g0 {
我的本意是从excel文件(50行、2列)中读取数据,分别作为横纵坐标,Z坐标赋值为0,然后画线
1 [5 `, R8 i% l7 |0 p( ]1 s* h程序不报错,也没反应,不知为何? |