×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Data from Exel

Data from Exel

Data from Exel

(OP)
Hi everybody,

I am wondering, is there any way to extrude data from Exel file and to use it in my lisp routine??

Please help

Zmei

RE: Data from Exel

Dear zliazmei,
There is some facilites lets you extract data from Excel and use it in AutoCAD. I will check it for you and if I find the way, I will let you know about it.
:)
Farzad

RE: Data from Exel

Hi,
I dont know if this will be of any use, but you can generate scripts from excel spreadsheets using scriptsheets.com scriptwriter(and its free).
Peter

RE: Data from Exel

Here is an excerpt from a Bill Kramer article at Autodesk:

;; Point A
;; A scroll from the Wizard's Lab.
;;
;; Bill Kramer 2002
;;
;; Interface with Excel Worksheet
;;
;; Global Variables
;;  xL  - Object reference to EXCEL instance
;;  myXLWbs - Object reference to EXCEL work books
;;  myXLWb1 - Object reference to Work book #1
;;  myXLShs - Object reference to Sheets in Work book
;;  myXLSh1 - Object reference to Sheet 1
;;  myXLNms - Object reference to list of named cells
;;
(vl-load-com)
;
;;-----------------------------------------------
;; Open link to EXCEL spreadsheet, use existing
;; instance of EXCEL if one exists otherwise
;; load EXCEL and then open the file supplied
;; as the variable xLFile.
;;
(defun Link_2_Excel (xLFile)
  (setq xL ;Attempt to open existing or create new Excel instance
     (vlax-get-or-create-object "Excel.Application"))
  (if xL ;;success?
    (progn
      (if (and xLFile (findfile xLFile)) ;;Was a file name supplied?
    (progn
      ;;
      ;; We have the application object, now we need to tunnel
      ;; down into a work book.
      ;;
      (if (null xl-open) ;;Check to see if type library defined
        ;;It is not, import the type library for EXCEL
        (vlax-import-type-library
          :tlb-filename "C:/Program Files/Microsoft Office/Office/Excel8.olb"
          :methods-prefix "xL-"
          :properties-prefix "xLp-"
          :constants-prefix "xLc-"))
      ;;
      ;; Now dig into the EXCEL object
      (setq myXLWbs (vlax-get xL "Workbooks") ;workbooks
        myXLWb1 (xl-open myXLWbs xLFile) ;open a workbook
        myXLShs (vlax-get myXLWb1 "Sheets") ;worksheets
        myXLSh1 (xlp-get-item myXLShs "Sheet1") ;worksheet number 1
        myXLNms (vlax-get myXLWb1 "Names") ;get reserve names
        )
    )
      )
   )
 )
  xL ;;return the object reference
)
;;----------------------------------------
;; Given a name that represents a variable in the EXCEL spreadsheet,
;; send the value in VAL to EXCEL.
;;
;; Note that the linkage to EXCEL MUST be determined before calling
;; this function!
;;
(defun Update_Variable (Varname  ;;Variable name
            Val      ;;Value to write to spreadsheet
            /
            TMP      ;;Named object reference
            Rng)     ;;Range in spreadsheet (location)
  (setq TMP
     (vl-catch-all-apply ;;Catch errors if they happen
          'vla-item ;;Get the name from the names collection
          (list
        myXLNMS ;;collection of names from Link_2_Excel
        VarName)))
  (if (and ;;No errors and item found?
    (not (vl-catch-all-error-p TMP))
    (setq Loc1 (vlax-get TMP "Value")))
    (progn ;;yes, get the range of the named item and update the value
      (setq Rng (xlp-get-range Sh1 Loc1))
      (xlp-put-value Rng Val)
    )
  )
)
;;-----------------------------------------------
;; Close the EXCEL spread sheet after saving it.
;;
(defun Close_XL (SaveFileName)
  (xl-saveas myXLSh1 SaveFileName)
  (xl-close myXLWb1)
)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources