AutoLISP 例程:读取 excel 文件
好多讲述用 vlisp 读取 excel 文件的文章中都提到 vlax—import—type—library 这个函
数,其实没有必要.该函数仅仅是给每个 excel 对象模型中的属性、方法、对象等引入一个别名,
占内存很大,没有意义。用 vlisp 操作 excel 文件只要了解 excel 对象模型和
vlax—get—or—create-object 、vlax-get—property、vlax—invoke-method、
vlax-put-property、vlax—safearray—type 几个函数就可以了。
下面的例子定义函数(GetCellValueAsList excelFile sheetName RangeStr) 读取如图
所示的 excel 表格内容,返回 list 类型。
(defun c:test()
(setq retV (GetCellValueAsList "E:
\CAD\AutoLISP\LEARNING\book1.xlsx” ”BOM" ”A4:E6"))
(princ)
)
(defun GetCellValueAsList( excelFile sheetName RangeStr / xl wbs wb shs sh rg cs vvv
nms nm ttt)
评论0