Leer Excel XLSX grande a un array o DBF

Post Reply
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Leer Excel XLSX grande a un array o DBF

Post by nageswaragunupudi »

leandro wrote:Amigo puedes hacerlo directamente desde Excel, esta función convierte el Excel a un array de tipo hash

Code: Select all | Expand


Function recupera(cRtaXls)
Local hLinea := {=>}
Local aDatos := {}
Local oExcel,oBook,oHoja
Local nTotRowCount := 0
Local nTotColCount := 0
Local nContador := 1

oExcel:= TOleAuto():New("Excel.Application")
oBook := oExcel:Workbooks:Open(cRtaXls)
oHoja := oExcel:Get( "ActiveSheet" )

nTotRowCount:= oHoja:UsedRange:Rows:Count()
nTotColCount:= oHoja:UsedRange:Columns:Count()

//oMeter:nTotal = nTotRowCount
//oMeter:Set( 0 )

FOR Q=1 TO nTotRowCount

    FOR b:=1 TO nTotColCount
        cNmcol := "COL"+cvaltochar(b)   
        hLinea[cNmcol] := oHoja:Cells( Q, b ):Value
    NEXT    
    AADD(aDatos,hLinea)
    hLinea := {=>}

    nContador++ 
    //oMeter:Set( nContador )   

NEXT
oExcel:WorkBooks:Close()
oExcel:Application:Quit()
oExcel:Quit()
oExcel := NIL

xbrowse(aDatos)

Return nil 
 
This can also be written as:

Code: Select all | Expand

oRange := GetExcelRange( cExelFileWithFullPath )
aData := xlRangeValue( oRange )
XBROWSER aData
Regards

G. N. Rao.
Hyderabad, India
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Leer Excel XLSX grande a un array o DBF

Post by Jimmy »

hi,

if you use FWH 64 Bit it is no Problem to use 1.000.000 Row of Excel Sheet with ADO without Array

Code: Select all | Expand

FUNCTION ADOsheet( cPathcFile )
LOCAL objRS, oBrw
LOCAL cSheet, cRange, lHeaders := .T.

   objRS := FW_OpenADOExcelSheet( cPathcFile, cSheet, cRange, lHeaders )
 
   @ nBhight,  2 XBROWSE oBrw SIZE nWidth - 20, nHeight - 90 PIXEL OF oWnd ;
              RECORDSET objRS FASTEDIT ;
              AUTOCOLS ;
              CELL LINES NOBORDER UPDATE ;
              FONT oFontDefault COLOR BFcolor, BGcolor
this CODE work also under 32 Bit but over 500.000 Row it might crash when MEMORY is low of 32 Bit App

---

instead of XBROWSE you can use Record-Set to create a DBF or SQL-Table
greeting,
Jimmy
Enrrique Vertiz
Posts: 549
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru
Contact:

Re: Leer Excel XLSX grande a un array o DBF

Post by Enrrique Vertiz »

Hi Mr. Rao

Unresolved external _HB_FUN_FW_GetExcelRange
Unresolved external _HB_FUN_xlValue

I use FWH 23.07, Thanks
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Leer Excel XLSX grande a un array o DBF

Post by karinha »

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Leer Excel XLSX grande a un array o DBF

Post by nageswaragunupudi »

Enrrique Vertiz wrote:Hi Mr. Rao

Unresolved external _HB_FUN_FW_GetExcelRange
Unresolved external _HB_FUN_xlValue

I use FWH 23.07, Thanks
Very sorry, I corrected the mistakes.
Please see my edited posting again.
the functions are:
GetExcelRange .. not FW_GetExcelRange
and
xlRangeValue ... not xlValue

Code: Select all | Expand

oRange := GetExcelRange( cExelFileWithFullPath )
aData := xlRangeValue( oRange )
XBROWSER aData
Regards

G. N. Rao.
Hyderabad, India
Enrrique Vertiz
Posts: 549
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru
Contact:

Re: Leer Excel XLSX grande a un array o DBF

Post by Enrrique Vertiz »

GRACIAS Karinha, Rao !!!
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Post Reply