Visual LISP, AutoLISP and General Customization
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How To Open Excell File
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
43 Views, 3 Replies
05-02-2006 01:58 AM
Hi All,
I have some data in an excell file and I want to use it just to querry. How can I open that excell file.
Regards
I have some data in an excell file and I want to use it just to querry. How can I open that excell file.
Regards
*Adesu
Re: How To Open Excell File
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-02-2006 02:07 AM in reply to:
Akdogan
To open Excell,here the simple code
(setq file "c:/YBI/Adesu/ext.xls") ; change with your file
(setq xlsfile (getfiled "Open Excel File" file "xls" 0))
(startapp (strcat "\"" "c:\\program files\\microsoft
office\\office\\Excel.exe" "\"")
(strcat "\"" xlsfile "\""))
wrote in message news:5160587@discussion.autodesk.com...
Hi All,
I have some data in an excell file and I want to use it just to querry. How
can I open that excell file.
Regards
(setq file "c:/YBI/Adesu/ext.xls") ; change with your file
(setq xlsfile (getfiled "Open Excel File" file "xls" 0))
(startapp (strcat "\"" "c:\\program files\\microsoft
office\\office\\Excel.exe" "\"")
(strcat "\"" xlsfile "\""))
Hi All,
I have some data in an excell file and I want to use it just to querry. How
can I open that excell file.
Regards
Re: How To Open Excell File
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-02-2006 02:30 AM in reply to:
Akdogan
Hi Kamil
See how it will work for you
[code]
(defun EXD ( / ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)
(vl-load-com)
(setq FilePath (getfiled "Select Excel file to read :"
(getvar "dwgprefix")
"xls"
16
)
)
(setq ShtNum 1)
(setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
(vla-put-visible ExcelApp :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 Sht 'UsedRange)
ExcData (vlax-safearray->list (vlax-variant-value
(vlax-get-property UsdRange 'Value))))
(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)
(if (not (vlax-object-released-p x))
(vlax-release-object x)
)
)
)
(list UsdRange Sht Wbk ExcelApp)
)
(setq UsdRange nil
Sht nil
Wbk nil
ExcelApp nil
)
(gc)
(gc)
ExcData
;;; or (mapcar (function (lambda (x)(mapcar 'atof x))) ExcData)
ExcData
)
; CaLL :
(setq data (exd))
[/code]
Fatty
~'J'~
See how it will work for you
[code]
(defun EXD ( / ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)
(vl-load-com)
(setq FilePath (getfiled "Select Excel file to read :"
(getvar "dwgprefix")
"xls"
16
)
)
(setq ShtNum 1)
(setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
(vla-put-visible ExcelApp :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 Sht 'UsedRange)
ExcData (vlax-safearray->list (vlax-variant-value
(vlax-get-property UsdRange 'Value))))
(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)
(if (not (vlax-object-released-p x))
(vlax-release-object x)
)
)
)
(list UsdRange Sht Wbk ExcelApp)
)
(setq UsdRange nil
Sht nil
Wbk nil
ExcelApp nil
)
(gc)
(gc)
ExcData
;;; or (mapcar (function (lambda (x)(mapcar 'atof x))) ExcData)
ExcData
)
; CaLL :
(setq data (exd))
[/code]
Fatty
~'J'~
Re: How To Open Excell File
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-02-2006 04:38 AM in reply to:
Akdogan
Hi Oleg,
Thank you for the code. It worked great for a little data, but I have to try it for a huge one. I think it will work again. I will write the result to you.
Regards...
Thank you for the code. It worked great for a little data, but I have to try it for a huge one. I think it will work again. I will write the result to you.
Regards...

