merged cells in excel

merged cells in excel

gcsjlewis
Collaborator Collaborator
1,210 Views
2 Replies
Message 1 of 3

merged cells in excel

gcsjlewis
Collaborator
Collaborator

I am using Autocad Electrical 2011.

 

I am trying to fix an issue when reading an excel file, and that occurs when there is a merged cell.

 

For the one spread sheet i am looking at cell "Q22" and i dump the properties to see this

 

(vlax-dump-object (vlax-get-property xl "RANGE" "Q22") T )

.

.

.

; Locked = 0
; MDX (RO) = ""
; MergeArea (RO) = #<VLA-OBJECT Range 000000005bf7cdb8>
; MergeCells = -1;;;;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>this tells me it is a merged cell, 0 means "unmerged".
; Name = Exception occurred
; Next (RO) = #<VLA-OBJECT Range 000000005bf7cf18>
; NumberFormat = "General"

.

.

.

 

When i go to get the value,it comes back

 

(vlax-get-property  (vlax-get-property xl "RANGE" "Q22") "mergecells" )  #<variant 11 -1>

 

This is where i am stuck and not too familiar with visual lisp, how do i check for the -1?

 

Thanks

 

0 Likes
Accepted solutions (1)
1,211 Views
2 Replies
Replies (2)
Message 2 of 3

Shneuph
Collaborator
Collaborator

I'm not familiar with querying excel that way and I'm not sure the value you are looking for is in the mergecells property or the mergearea property but you can keep digging with this:

 

(vlax-variant-value (vlax-get-property  (vlax-get-property xl "RANGE" "Q22") "mergecells"))

 

I don't know what this will return but when I use it it's often a safearray.  So, if that's what you get you can use.

 

(setq mylist (vlax-safearray->list (vlax-variant-value (vlax-get-property  (vlax-get-property xl "RANGE" "Q22") "mergecells")))

 

and then dig around in mylist for the info you're looking for.

 

Hope this helps at least a little.

 

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 3

patrick_35
Collaborator
Collaborator
Accepted solution

Hi

 

Try

(vlax-get (vlax-get-property xl 'range "Q22") 'mergecells)

@+

0 Likes