Array TO XLS ?
Posted: Wed Apr 15, 2020 8:18 pm
hola,
existe una funcion como FW_CopyDBF2XL(), pero para ArrayToXLS() ?
Gracias!
existe una funcion como FW_CopyDBF2XL(), pero para ArrayToXLS() ?
Gracias!
www.FiveTechSoft.com
https://forums.fivetechsoft.com/
Code: Select all
(cAlias)->( FW_DbfToExcel( [cFieldList], [bFor], [bWhile], [nNext], [nRec], [lRest], [cSaveToFileName] )
Code: Select all
FW_CopyDBFTO( [cDestXLS], [cSourceDBF] )
Code: Select all
function ArrayToExcel( aData )
local oExcel, oBook, oSheet
local nRow, nCol, nCols := 1
if ( oExcel := ExcelObj() ) == nil
? "Excel not instqalled"
else
oBook := oExcel:WorkBooks:Add()
oSheet := oBook:ActiveSheet
oExcel:ScreenUpdating := .f.
for nRow := 1 to Len( aData )
if ValType( aData[ nRow ] ) == "A"
nCols := Max( nCols, Len( aData[ nRow ] ) )
for nCol := 1 to Len( aData[ nRow ] )
oSheet:Cells( nRow, nCol ):Value := aData[ nRow, nCol ]
next
else
oSheet:Cells( nRow, 1 ):Value := aData[ nRow ]
endif
next
oSheet:Range( oSheet:Columns( 1 ), oSheet:Columns( nCols ) ):AutoFit()
oExcel:ScreenUpdating := .t.
oExcel:visible := .t.
endif
return nil
function ArrayToExcel2( aData )
local oExcel, oBook, oSheet
local cText, oClp, nCols := 0
if ( oExcel := ExcelObj() ) == nil
? "Excel not instqalled"
else
oBook := oExcel:WorkBooks:Add()
oSheet := oBook:ActiveSheet
oExcel:ScreenUpdating := .f.
aData := AClone( aData )
AEval( aData, { |a| nCols := Max( nCols, Len( a ) ) } )
AEval( aData, { |a,i| aData[ i ] := FW_ArrayAsList( a, Chr( 9 ) ) } )
cText := FW_ArrayAsList( aData, CRLF )
oClp := TClipboard():New()
oClp:SetText( cText )
oSheet:Cells( 1, 1 ):Select()
oSheet:Paste()
oClp:Clear()
oClp:End()
oSheet:Range( oSheet:Columns( 1 ), oSheet:Columns( nCols ) ):AutoFit()
oExcel:ScreenUpdating := .t.
oExcel:visible := .t.
endif
return nil