Generating excel data in different sheets using AutoLISp

Generating excel data in different sheets using AutoLISp

sanju.p
Enthusiast Enthusiast
1,295 Views
5 Replies
Message 1 of 6

Generating excel data in different sheets using AutoLISp

sanju.p
Enthusiast
Enthusiast
Hello everyone,

Is it possible to generate data in different sheet in same excel file by using AutoLISP.
If so, I kindly request you to suggest me on this.

Thanks in advance
Basic learner.
0 Likes
1,296 Views
5 Replies
Replies (5)
Message 2 of 6

Yamishon_Noah
Enthusiast
Enthusiast

Provide input files and elaborate more!

 

you want to export data from autocad to excel in different worksheets?

0 Likes
Message 3 of 6

sanju.p
Enthusiast
Enthusiast
Sir,

If you consider a rectangle, it's length and height are exported in first worksheet from AutoCAD

And the same if you consider a square it's length exported from AutoCAD in other worksheets of same excel file.

File named-
dimensions.xls
0 Likes
Message 4 of 6

jwhite
Advocate
Advocate

You can use:

  (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application"))
  (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$)
  (if SheetName$
    (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets")
      (if (= (vlax-get-property Worksheet "Name") SheetName$)
        (vlax-invoke-method Worksheet "Activate")
      );if
    );vlax-for
  );if

where SheetName$ is the name of the worksheet to activate

0 Likes
Message 5 of 6

sanju.p
Enthusiast
Enthusiast
Thank you for kind response.
I will let you know, once I get output.
0 Likes
Message 6 of 6

sanju.p
Enthusiast
Enthusiast

When I try below method.

I found

 

; error: ActiveX Server returned the error: unknown name: A2E

 

 

 

 

(setq
  a1(getpoint"\n pick point:")
  a2(polar a1 0 500)
  a3(polar a2 (* 0.5 pi) 1000)
  a4(polar a3 pi 500)

  w1(distance a1 a2)
  h1(distance a2 a3)
width(rtos w1 2 0)
height(rtos h1 2 0)
)
  (command
    "pline"a1 a2 a3 a4"c")
    
(setq f(open "d:\\a2e.xls""a"))
(write-line s3 f)
 (close f)
 
(setq *ExcelApp%(vlax-get-or-create-object "Excel.Application"))
  (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'a2e.xls)

  (if sheet2
    (vlax-for Worksheet(vlax-get-property *ExcelApp% "Sheets")
      (if (= (vlax-get-property Worksheet "Name") sheet2)
    (vlax-invoke-method Worksheet "Activate")
    )
      )
    )
 
 (setq
S3(strcat width"\t"height)
  )
            
(setq f(open "d:\\a2e.xls""a"))
(write-line s3 f)
 (close f)

0 Likes