Hello .....
delving into the topic of reading XLS sheets .... a little program that puts the contents of a multi-sheet XLS list in a list (LIST) for AutoLISP ...
Works with DLL "excellisp.dll" and A2008 and excel 2003 is going great ...
The only requirement is that the XLS with a sheet called "PORTADA"
Each sheet of each book is found throughout the height and width, creating a sublist by row entire
eye with that.
ATTENTION: THERE A PATH AND FORMAT OF OUTPUT IS THE LIST OF SOME PARTICULAR ... as "listed" using APPEND and CONS ... Change it according to your needs ...
( defun c:lee_xls ( / )
( if ( not Excel_Release )
( command "netload" ( findfile "ExcelLisp.dll" ) )
)
( setq lista_xls '(
"sector_2" ;<<< examples !!!
"sector_4"
"sector_5"
)
)
( setq list-data-colec '() )
( foreach libro lista_xls
( setq excel-libro ( strcat "c:\\codif\\" libro ".xls" ) ) ;<<<<<<<<< path !!!
( Excel_Conecta T excel-libro "PORTADA" )
( setq lista-hojas ( Excel_ListaHojas ) )
( setq lista-hojas ( vl-remove "PORTADA" lista-hojas ) )
( setq list-data-libro '() )
( foreach hoja lista-hojas
( Excel_Hoja hoja )
; ( print hoja )
( setq extremos (Excel_Ultimos) )
; ( print extremos )
( setq col-ini ( car extremos ) )
( setq fil-ini ( cadr extremos ) )
( setq col-fin ( caddr extremos ) )
( setq fil-fin ( cadddr extremos ) )
( setq list-data-hoja '() )
( setq contf fil-ini )
( repeat ( - fil-fin fil-ini )
( setq contc col-ini )
( setq list-data-fila '() )
( repeat ( - col-fin col-ini )
( setq valor ( Excel_Dato contc contf nil t ) )
; ( print valor ) ( getint "valor" )
( setq list-data-fila ( append list-data-fila ( list valor ) ) )
( setq contc ( 1+ contc ) )
)
( setq list-data-hoja ( append list-data-hoja ( list list-data-fila ) ) )
; ( print list-data-hoja ) ( getint "list-data-hoja" )
( setq contf ( 1+ contf ) )
)
( setq list-data-libro ( append list-data-libro ( list ( cons hoja list-data-hoja ) ) ) )
; ( print list-data-libro ) ( getint "list-data-libro" )
) ; foreach hojas
( setq list-data-colec ( append list-data-colec ( list ( cons excel-libro list-data-libro ) ) ) )
( Excel_Release )
)
list-data-colec
)
The first work seems to hang, but it takes a few seconds to open Excel and load the pages ...
I hope you find it useful ....
In another order: very interesting possibility to order the registry data with tabs. I never used. I'll try. Thanks for the idea.
Greetings ....
PS:
"lee"_xls is in spanish
"read"_xls ( no
LeeMac_xls )
PS: attached the DLL used.