Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

passing an array of values to an Excel range with vlisp

37 views
Skip to first unread message

Marc'Antonio Alessi

unread,
Aug 12, 2003, 1:33:34 PM8/12/03
to
search: autodesk.autocad.customization

Excel Quit: new behaviour - Excel: multi range - Excel quit

--
________________________________________________

Marc'Antonio Alessi (TV) Italy
(strcat "NOT a " (substr (ver) 8 4) " guru.")

O.S. = XP Pro 2002 - Sp.1 - Ita
AutoCAD = 2002 Ita - Sp.1
_VERNUM = "K.0.44"
ACADVER = "15.06s (LMS Tech)"
(ver) = "Visual LISP 2000 (it)"
________________________________________________

Mark

unread,
Aug 13, 2003, 10:14:34 AM8/13/03
to
i am passing a two dimensional safe-array, and works fine,
this is a snipset from my code...
using :properties-prefix "xlp-"
xlas = the active sheet object

(setq mmls '((5.5 4 33 "O")(nil 6.6 44 "K")(7 nil 7.7 "MM")))
(xlp-put-value (xlp-get-range xlas "A1:D3")
(vlax-safearray-fill
(vlax-make-safearray vlax-vbVariant (cons 0 (1- (length mmls)))
(cons 0 (1- (length (car mmls)))))
(mapcar '(lambda (itm) (mapcar 'vlax-make-variant itm)) mmls)))

HTH

"PeterSCiganek" <peter....@schuster-pechtold.de> wrote in message
news:f17ff...@WebX.maYIadrTaRb...
> I am trying to pass a single dimension safe-array to a range in Excel. For some reason - the range
only accepts the first atom of the array. This is how the code excecutes:
> (setq range_object (vlax-get-property worksheet_object 'Range "A1:A6"))
>
> (vlax-put-property range_object 'Value2 safe_array)
>
> The safe array is correctly typed and does contain separate values.
>
> I am currently passing each value individually to a cell - and am hoping to speed up the transfer
of data by passing arrays. What am I doing wrong?
>
> Thanks for any help,
>
> Peter
>
>


Marc'Antonio Alessi

unread,
Aug 13, 2003, 9:16:22 PM8/13/03
to
Search on Google:
Excel Quit: new behaviour
autodesk.autocad.customization - 2003-04-29 , Marc'Antonio Alessi

and
Search: Visual LISP ActiveX API for Excel - reposted
on autodesk.autocad.customer-files 2003-05-22

HTH

Marco

Marc'Antonio Alessi

unread,
Aug 13, 2003, 10:19:14 PM8/13/03
to
Reading Mark post:

;
; ALEax_Make2DimSafeArray (original by Mark)
; Argument: a list
; Examples:
; (ALEax_Make2DimSafeArray '((5.5 4 33 "O")(nil 6.6 44 "K")(7 nil 7.7
"MM")))
;
(defun ALEax_Make2DimSafeArray (ImpLst)
(vlax-safearray-fill
(vlax-make-safearray vlax-vbVariant
(cons 0 (1- (length ImpLst))) (cons 0 (1- (length (car ImpLst))))
)
(mapcar '(lambda (x) (mapcar 'vlax-make-variant x)) ImpLst)
)
)
(defun C:XlNew ( )
(vl-load-com)
(setq
*ExcelApp* (vlax-get-or-create-object "Excel.Application")
*ActiveWbk*
(vlax-invoke-method
(vlax-get-property *ExcelApp* 'WorkBooks) 'Add
)
*ActiveSht* (vlax-get-property *ExcelApp* 'ActiveSheet)
*ActiveCls* (vlax-get-property *ActiveSht* 'Cells)
)
(vla-put-visible *ExcelApp* 1)
(setq
RngObj
(vlax-get-property
*ActiveSht* 'Range
"A1:D3"
)
)
(vlax-put-property RngObj 'Value2
(ALEax_Make2DimSafeArray


'((5.5 4 33 "O")(nil 6.6 44 "K")(7 nil 7.7 "MM"))
)

)
)
(defun C:XlClose ( )
(vlax-release-object RngObj) ;<<
(vlax-release-object *ActiveCls*)
(vlax-release-object *ActiveSht*)
(vlax-invoke-method *ActiveWbk* 'Close 0)
(vlax-release-object *ActiveWbk*)
(vlax-invoke-method *ExcelApp* 'QUIT)
(vlax-release-object *ExcelApp*)
(setq
*ExcelApp* nil *ActiveWbk* nil *ActiveSht* nil *ActiveCls* nil
RngObj nil
)
(gc)
)

Mark

unread,
Aug 14, 2003, 8:22:23 AM8/14/03
to
hi Marco,

any luck on the nested rectangles...

very much interested to know what

algorithm others are using.

Mark

BTW

Peter also should know that

the list and the range string should

be in sync, othewise the result will

be incorrect, i.e.

"A1:D3" and

'((A1 B1 C1 D1)(A2 B2 C2 D2)(A3 B3 C3 D3))

or

"A1:A5" and

'((A1)( A2 )(A3)( A4 )(A5))


"Marc'Antonio Alessi" <maalessi at tin dot it> wrote in message
news:CE1ACFD7B660AE93...@in.WebX.maYIadrTaRb...

Marc'Antonio Alessi

unread,
Aug 14, 2003, 12:52:13 PM8/14/03
to
Hi Mark,

no news, I have given a glance to

www.techno-sys.com www.nirvanatec.com

but I have not tried any more.

Cheers.

Marco

0 new messages