Author Topic: Multiple Excel xls datas in a multiple box dcl dialog, be interesting?  (Read 2198 times)

0 Members and 1 Guest are viewing this topic.

SOFITO_SOFT

  • Guest
Based in a example of multiple list box (Lee Mac, thanks!!! ) with Datas of multiple xls files ...
It works, but a little rough ...



Someone interested in the topic?
Greeting...

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Looks interesting, and would perhaps be useful for those looking to learn how to read an Excel file.

Although I'm not sure how clear it would be to display the cellular format of Excel data using the list format of a DCL list_box. From your example it looks like you are using spaces to separate columns (this would run into trouble if the data also contained spaces), I would maybe opt to use tabs with the 'tabs' attribute set accordingly for the DCL list_box, and with the 'tab_truncate' attribute set to true.

Glad I could help with the multiple list_box setup. :-)

SOFITO_SOFT

  • Guest
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 ...
Code: [Select]
( 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.

DEVITG

  • Bull Frog
  • Posts: 481
Re: Multiple Excel xls datas in a multiple box dcl dialog, be interesting?
« Reply #3 on: August 13, 2012, 08:15:00 PM »
Hi Sofito , how can I use  "excellisp.dll" to open a XLS , if the HOJA or  sheet , is not known ?
As the XLS cloud come from any language , HOJA1 ,  sheet1, or whatever the user name it .
Could I use a wildcard ?
Did you any upgrade at the "excellisp.dll"?
Thanks in advance .
 
Location @ Córdoba Argentina Using ACAD 2019  at Window 10