Read excel cells and create list.

Discussion in 'AutoCAD' started by amitvedak, Dec 22, 2004.

  1. amitvedak

    amitvedak Guest

    Hello friends,

    Here I am facing a problem in reading excel file through lisp.
    I hade download program from this discussions and edited .but it takes too much time for output

    Does anybody having program of reading excel file and list same like read-line function of auto lisp

    My requirements is as below

    Contains of excel file
    1000 2000 3000 4000 5000 6000 7000

    After reading excel file I need these values in list
    Example (“1000†“2000†“3000†“4000†“5000†“6000†“7000â€)

    Also I need this in loop next lines 1 by one.
    Gentlemen’s pls. help me in this.

    Regards
    Amit
     
    amitvedak, Dec 22, 2004
    #1
    1. Advertisements

  2. amitvedak

    Dann Guest

    This example should get you started: .....Or at least get this thread
    started :)

    (setq l1 "1000 2000 3000 4000 5000 6000 7000")
    (setq l2 nil)
    (repeat 7
    (setq l1 (vl-string-left-trim " " l1))
    (setq tst (rtos (atoi l1) 2 0))
    (setq l2 (cons tst l2))
    (setq l1 (vl-string-left-trim tst l1))
    )
    (setq l2 (reverse l2))
     
    Dann, Dec 22, 2004
    #2
    1. Advertisements

  3. amitvedak

    kozmos Guest

    you can read/write "vlaue2" property of Excel range vla-object and then conver data between the variant and VL list. This will have a same speed as VB do.
     
    kozmos, Dec 23, 2004
    #3
  4. amitvedak

    amitvedak Guest

    values shud not be in lisp format
    (setq l1 "1000 2000 3000 4000 5000 6000 7000")
    are in diff. excel cells
    1000 2000 3000 4000 5000 6000 7000
    pls. tell me again if u kno.

    amit
     
    amitvedak, Dec 23, 2004
    #4
  5. amitvedak

    amitvedak Guest

    thanks 4 reply.

    do u have any sample program. coz i am not familer with vlisp functions

    amit
     
    amitvedak, Dec 23, 2004
    #5
  6. amitvedak

    kozmos Guest

    You can go to http://www/ikozmos.com to download VLXLS.
    There is a sample file to show the data exchanged between ACAD and Excel

    Following is a very simple to conver Excel data into VL list:

    First of all, please load VLXLS.LSP (or vlxls-* functions will not work) and make sure an Excel session with data is opened and set as current active spreadsheet. The codes below will convert all Excel data into VL List

    (vlxls-app-init) ;;;Initialize Link between Excel/ACAD
    (setq *xl* (vlax-get-object "Excel.Application")) ;;; Get the Excel VLA-Object
    (if *xl* (setq Range (vlxls-sheet-get-usedrange *xl* nil))) ;;; Get all used range vla-object
    (if Range (setq value (vlax-get-property Range "Value2") ;;; Get the variant value
    value (vlxls-variant->list value) ;;; Convert Variant into VL list
    ))
    (vlax-release-object range)
    (vlax-release-object *xl*) ;;; Release the vla-object

    The return value is a two dimension list, similia format is
    '(("" "" "" "")
    ("" "" "" "")
    ("" "" "" "")
    ....
    )
     
    kozmos, Dec 24, 2004
    #6
    1. Advertisements

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.