guitarguy1685 Posted March 24, 2010 Posted March 24, 2010 Can I use LISP to read XCELL data or does this need to be done through vba or vb.net? Quote
Lee Mac Posted March 24, 2010 Posted March 24, 2010 Yes, you can use LISP, a quick example is Terry Miller's GetExcel: http://web2.airmail.net/terrycad/LISP/GetExcel.lsp Quote
JohnM Posted March 24, 2010 Posted March 24, 2010 you can use lisp. search this fourm and you should find many examples. everyones needs are diffrent but the general connection is the same Quote
fixo Posted March 24, 2010 Posted March 24, 2010 Can I use LISP to read XCELL data or does this need to be done through vba or vb.net? Give this a shot (vl-load-com) (defun read_excel_range (FilePath ShtNum Address / ExcelApp ExcData Sht UsdRange Wbk) (setq ExcelApp (vlax-get-or-create-object "Excel.Application")) (vla-put-visible ExcelApp :vlax-true) (vlax-put-property ExcelApp 'DisplayAlerts :vlax-true) (setq Wbk (vl-catch-all-apply 'vla-open (list (vlax-get-property ExcelApp "WorkBooks") FilePath) ) ) (setq Sht (vl-catch-all-apply 'vlax-get-property (list (vlax-get-property Wbk "Sheets") "Item" ShtNum ) ) ) (vlax-invoke-method Sht "Activate") (setq UsdRange (vlax-get-property (vlax-get-property Sht 'Cells) "Range" Address) ExcData (vlax-safearray->list (vlax-variant-value (vlax-get-property UsdRange 'Value2) ) ) ) (setq ExcData (mapcar (function (lambda (x) (mapcar 'vlax-variant-value x))) ExcData ) ) (vl-catch-all-apply 'vlax-invoke-method (list Wbk "Close") ) (vl-catch-all-apply 'vlax-invoke-method (list ExcelApp "Quit") ) (mapcar (function (lambda (x) (vl-catch-all-apply (function (lambda () (progn (if (not (vlax-object-released-p x)) (progn (vlax-release-object x) (setq x nil) ) ) ) ) ) ) ) ) (list UsdRange Sht Wbk ExcelApp) ) (gc) (gc) (gc) ExcData ) (defun C:demo() (if (setq xlpath (getfiled "* Select Excel File *" "" "xls" 4) ) (progn (setq excel_data (read_excel_range xlpath "Sheet1" "A1:E15"));<--change to suit (princ excel_data);<--debug only ;| work further with data here |; ) ) (princ) ) ~'J'~ Quote
alanjt Posted April 9, 2010 Posted April 9, 2010 how to use this code? Im new in lisp... http://www.cadtutor.net/forum/showthread.php?t=1390 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.