如何直接从acad直接读取excel数据
bcaptain007
2022年08月10日 10:50:39
只看楼主

 ;;新建工作表,用于导出数据。 (GetPy wb 39;sheets) 是工作表集合对象   (setq sht (vlax-invoke-method (GetPy wb 39;sheets) 39;add))   ;;得到工作表的 cells 对象,该对象与 range 对象的区别就是可以用行列定位   (setq xcells (GetPy sht 39;cells)

 ;;新建工作表,用于导出数据。 (GetPy wb 39;sheets) 是工作表集合对象

  (setq sht (vlax-invoke-method (GetPy wb 39;sheets) 39;add))

  ;;得到工作表的 cells 对象,该对象与 range 对象的区别就是可以用行列定位

  (setq xcells (GetPy sht 39;cells)

    r      0

    c      0

  )

  (if (= (type Lit) 39;LIST)

    (repeat (length Lit)

      (setq d (nth r Lit)

        r (1 r)

      )

      (if (= (type d) 39;LIST)        ;如果lit的子项仍然是个表则继续循环取出

    (repeat (length d)

      (PutPy xcells 39;item r (1 c) (vl-princ-to-string (nth c d)))

      (setq c (1 c))

    )

    (PutPy xcells 39;item r 0 (vl-princ-to-string d))

                    ;修改了写入excel的顺序

      )

      (setq c 0)

    )

    (PutPy xcells 39;item 1 1 (vl-princ-to-string Lit))

  )

  (vla-put-visible *appxls* 1)

  ;;显示工作表

  (vlax-release-object xcells)

  ;;用完销毁

  (vlax-release-object sht)

  (vlax-release-object *appxls*)

)



相关推荐

APP内打开