Está en la página 1de 1

(defun sel->put-excel (/ conjSel cnt tmpValor)

(setq conjSel (ssget '((0 . "TEXT"))))


(if (null conjSel)
(exit))
(setq cnt 0)
(conecta-excel)
(repeat (sslength conjSel)
(setq tmpValor (atof (cdr (assoc '1 (entget (ssname conjsel cnt))))))
(dato->celda (+ cnt 1) 1 (vl-string-subst "," "." (rtos tmpValor 2 2)))
(setq cnt (+ cnt 1))
)
(desconecta-excel)
)
(defun desconecta-excel()
(vlax-release-object col-celdas)
(vlax-release-object hoja-1)
(vlax-release-object col-hojas)
(vlax-release-object new-libro)
(vlax-release-object col-libros)
(vlax-release-object apl-excel)
(gc)
)
(defun conecta-excel()
(setq apl-excel (vlax-get-or-create-object "excel.application")
col-libros (vlax-get-property apl-excel "workbooks")
new-libro (vlax-invoke-method col-libros "add")
col-hojas (vlax-get-property new-libro "sheets")
hoja-1
(vlax-get-property col-hojas "item" 1)
col-celdas (vlax-get-property hoja-1 "cells"))
(vla-put-visible apl-excel :vlax-true))
(defun dato->celda (fila col valor)
(vlax-put-property col-celdas "item" fila col (vl-princ-to-string valor)))

También podría gustarte