明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2631|回复: 4

请教如何用LISP程序读取电子表格excel中的数据?

[复制链接]
发表于 2005-1-29 16:32:00 | 显示全部楼层 |阅读模式
请教如何用LISP程序读取电子表格excel中的数据?
发表于 2005-1-30 12:21:00 | 显示全部楼层
参考http://www.ikozmos.com 中的VLXLS
发表于 2005-2-21 10:52:00 | 显示全部楼层
怎么写入那?比如说在ACAD中,有一些文字,按照我点选的顺序以次存入EXCEL中,且在E中是按列排序,就是输入一个,回车自动,输入一个,自动回车……选定第一个单元格,然后以次写入它下面的一列单元格。
发表于 2005-2-21 14:58:00 | 显示全部楼层
(defun exl-pro (/ exl-app exl-workb exl-file exl-sheet exl-rep1 exl-cont exl-t2 exl-rep2 exl-list2 exl-val)
(if exl-road
(setq exl-road (getfiled "Select a Excel file " exl-road "xls" 0))
(setq exl-road (getfiled "Select a Excel file " "" "xls" 0))
)
(if (not exl-road)
(start-end nil)
)
(princ "\nReading file !!! Please Wait ..........")
(setq exl-app (vlax-get-or-create-object "EXCEL.application"))
(if (not exl-app)
(progn
(alert "\nThis computer hasn't setup EXCEL application !!!")
(start-end nil)
)
)
(if (equal nil msEC-XLBAR)
(vlax-import-type-library
:tlb-filename
(strcat (vlax-get-property exl-app "Path") "\\xl5cht32.olb")
:methods-prefix
"MSEM-"
:properties-prefix
"MSEP-"
:constants-prefix
"MSEC-"
)
)
(vlax-put-property exl-app "DisplayFullScreen" :vlax-true)
(vlax-put-property exl-app "DisplayFullScreen" :vlax-false)
(setq exl-workb (vlax-get-property exl-app "workbooks")
exl-file (msem-open exl-workb exl-road)
exl-sheet (vlax-get-property exl-file "activesheet")
)
(setq exl-rep1 2
exl-list1 nil
exl-cont t
)
(while exl-cont
(setq exl-t2 (itoa exl-rep1)
exl-rep2 0
exl-list2 nil
)
(repeat 6
(setq exl-t1 (chr (+ 65 exl-rep2))
exl-t3 (strcat exl-t1 exl-t2 ":" exl-t1 exl-t2)
)
(setq exl-val (vlax-variant-value (vla-get-value (vlax-get-property exl-sheet "range" exl-t3))))
(if exl-val
(if (= exl-rep2 0)
(setq exl-list2 (cons (fix exl-val) exl-list2))
(setq exl-list2 (cons exl-val exl-list2))
)
(setq exl-cont nil)
)
(setq exl-rep2 (1+ exl-rep2))
)
(setq exl-list1 (cons (reverse exl-list2) exl-list1))
(setq exl-rep1 (1+ exl-rep1))
)
(setq exl-list1 (reverse (cdr exl-list1)))
(msem-close exl-file)
(vla-quit exl-app)
(princ)
) 这是一个从Excel读入数据的子程序,希望能帮到你
发表于 2005-2-21 17:33:00 | 显示全部楼层
我好像运行不了呀。埃 看看lisp还能看看,加了VLA-等的东西感觉就复杂了,看也看不懂
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-17 17:46 , Processed in 0.187582 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表