Lisp - Excel ?

Discussion in 'AutoCAD' started by media, Feb 10, 2004.

  1. media

    media Guest

    Bonjour tout le monde,
    je suis programmeur autolisp et j'aimerais toujours utiliser ce langage
    pour des liaisons et traitements avec Excel..je cherche tout liens ou
    documents me permettant de gérer des fichiers excel depuis AutoCAD grâce
    à lisp, comme chercher des valeurs de certaines cellules ou envoyer des
    données vers un fichier, créer des feuilles ou fichiers excel, faire des
    calculs, filtres dans Excel et bien sûr toujours depuis lisp..

    encore merci pour votre aide...
     
    media, Feb 10, 2004
    #1
  2. media

    Devin Guest

    Bonjour tout le monde,
    Can anybody translate?
     
    Devin, Feb 10, 2004
    #2
  3. media

    Jason Rhymes Guest

    Hello everyone, I am a programmer autolisp and I would always like to use
    this language for connections and treatments with Excel..je seeks any bonds
    or documents enabling me to manage Excel files since AutoCAD thanks to lisp,
    like seeking values of certain cells or sending data towards a file, to
    create sheets or Excel files, to make calculations, filters in Excel and of
    course always since lisp.. still thank you for your assistance...


    Translated at http://world.altavista.com/
     
    Jason Rhymes, Feb 10, 2004
    #3
  4. media

    ffejgreb Guest

    Well then. That's much clearer. Don't you just love those translators? Me
    thinks only 100 monkeys are in use.
     
    ffejgreb, Feb 10, 2004
    #4
  5. media

    Mark Propst Guest

    heres a couple clips i saved from past google search
    try searching google for more info on connecting to excel via lisp

    From: "John Uhden" <>
    Subject: Re: VLisp/ActiveX <---> Excel (2000i)
    Date: Sunday, November 04, 2001 9:44 AM

    I've found out just how slow it is! Finally developed a much faster
    method...

    1. Derive the Excel ProgID from the registry.
    2. Attach to Excel using (Vlax-get-or-create-object ProgID) and open a
    file.
    3a. Invoke a SAVEAS to a temporary tab-delimited .TXT file (use type 3).
    3b. Probably have to invoke a "SendKeys" "N" to dispose of Excel's annoying
    dialog.
    4. Invoke a QUIT from Excel.
    5. Read/parse the temporary TXT file into lists.
    6. Delete the temporary TXT file.
    7.... Manipulate the lists.

    This method avoids loading the Type Library, which by the way creates about
    2900 atoms that need to be cleared from AutoCAD's memory.

    Studying the values reported by (mem), it appears that my 46x31780 array of
    lists uses up about 64Mb of memory. No wonder my 128Mb laptop is
    struggling.

    To put data into Excel cells will probably require loading the Type Library,
    but that's for later.



    and another one:
    From: "Marc'Antonio Alessi" <maalessi at tin dot it>
    Subject: Re: About using vlax-import-type-library
    Date: Wednesday, April 09, 2003 12:16 PM

    Thanks for replay Doug,
    Yes

    This is what I am doing (it is a mix from Reini U. and David Stein)
    is it a good approach (sorry for word-wrap)?


    ;(setq *EXCEL-IMPORTALL* T)
    (defun MSX_Load-TypeLib ( / XlsInf)
    (cond
    ( (and (not msxm-Clear) (not *EXCEL-IMPORTALL*))
    (defun msxm-Clear (cell) (vlax-invoke-method
    cell 'Clear))
    (defun msxm-Add (collection) (vlax-invoke-method
    collection 'Add))
    (defun msxp-get-Item (range row col) (vlax-get-property range
    "Item" row col))
    (defun msxp-get-ActiveCell (msx) (vlax-get-property
    msx 'ActiveCell))
    (defun msxp-get-ActiveSheet (msx) (vlax-get-property
    msx 'ActiveSheet))
    (defun msxp-get-value (cell) (vlax-get-property
    cell "Value"))
    (defun msxp-get-cells (range) (vlax-get-property
    range "Cells"))
    (defun msxp-get-Interior (range) (vlax-get-property
    range 'Interior))
    (defun msxp-put-value (cell value) (vlax-put-property cell
    "Value" value))
    (defun msxp-put-value2 (cell value) (vlax-put-property cell
    "Value2" value))
    (defun msxp-put-ColorIndex (range color) (vlax-put-property range
    'ColorIndex color))
    (setq msxc-xlDecimalSeparator 3)
    )
    ( (or msxc-xl24HourClock) ); msxl-xl24HourClock fa parte di
    XlApplicationInternational
    ( (setq XlsInf (MSX_TypeLib))
    (princ (strcat "\nInitializing Microsoft Excel " (caddr XlsInf)
    "..."))
    (vlax-import-type-library
    :tlb-filename (strcat (car XlsInf) (cadr XlsInf))
    :methods-prefix "msxm-" :properties-prefix "msxp-"
    :constants-prefix "msxc-"
    )
    )
    )
    )

    (defun ALE_GetAppPath (AppNam)
    (vl-registry-read
    (strcat
    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App
    Paths\\"
    AppNam
    )
    "Path"
    )
    )

    (defun MSX_GetPath ( )
    (ALE_GetAppPath "Excel.exe")
    )


    (defun MSX_TypeLib ( / XlsPat)
    (setq XlsPat (MSX_GetPath))
    (cond
    ( (= (vl-filename-base (vl-filename-directory XlsPat)) "Office10") (list
    XlsPat "Excel.exe" "2002") )
    ( (vl-file-systime (strcat XlsPat "Excel9.olb" )) (list
    XlsPat "Excel9.olb" "2000") )
    ( (vl-file-systime (strcat XlsPat "Excel8.olb" )) (list
    XlsPat "Excel8.olb" "97" ) )
    )
    )
     
    Mark Propst, Feb 10, 2004
    #5
  6. media

    SpeedCAD Guest

    SpeedCAD, Feb 11, 2004
    #6
  7. media

    Devin Guest

    Maybe 99 :)
     
    Devin, Feb 11, 2004
    #7
  8. media

    bruno Guest

    media:

    .... Et j'en profite pour demander aux francophones qui passeraient par
    ici, s'il n'y a pas de forum autocad/lisp en francais ??
     
    bruno, Feb 12, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.