Newsgroup: it.comp.lang.vo-clipper
Titolo: x massimo bighelli

Scusa il disturbo,
hai poi trovato quella funzione che permetteva di trasferire dei dati da vo 
in excel.??
Grazie in ogni caso
Francesco D'Aquila

 ha scritto nel messaggio 
news:49c4bb35$0$1108$4faf...@reader3.news.tin.it...


 ha scritto nel messaggio
news:49c4bb35$0$1108$4faf...@reader3.news.tin.it...

Questo metodo esporta i dati da bBrowser in Excel
Saluti
Paolo Kalc
METHOD BBExportXL() CLASS MybBrowser
LOCAL oExcel AS _1Application
LOCAL oWorkbooks AS _WorkBooks
LOCAL oWorksheet AS _WorkSheet
LOCAL oRange AS _Range
LOCAL aHeadArray, aLineArray, aFootArray AS ARRAY
LOCAL dwLine as DWORD
local dwCount as longint
local dwMaxCol as longint
LOCAL sXLCol AS STRING
LOCAL uItem, uValue AS USUAL
LOCAL sValue AS STRING
LOCAL oPointer AS Pointer
LOCAL cbOldErrorHandler AS CODEBLOCK
IF SELF:Server = NULL_OBJECT
RETURN FALSE
ENDIF
cbOldErrorHandler := ErrorBlock( { |oError| _Break(oError) } )
oPointer := SELF:owner:Pointer
SELF:owner:Pointer := Pointer{ POINTERHOURGLASS}
BEGIN SEQUENCE
oExcel := _1Application{"Excel.Application"}
oExcel:SheetsInNewWorkbook := 2
oWorkbooks := oExcel:Workbooks
oWorkbooks:Add()
oWorksheet := oExcel:MyActiveSheet
oWorksheet:Name := "EXPORT da VO"
IF oExcel = NULL_OBJECT
RETURN FALSE
ENDIF
SELF:Server:SuspendNotification()
aHeadArray := {}
aLineArray := {}
aFootArray := {}
// get the column captions for the first row
dwMaxCol := SELF:ColumnOpenCount
FOR dwCount := 1 UPTO dwMaxCol
uItem := SELF:GetOpenColumn(dwCount):Caption
// Here we need to check to see if the caption is made up from a compound
value
// or whether it is just a string. Compund values are used when sorting IS
allowed
// on the bBrowser columns.
IF IsString(uItem)
sValue := RTrim( uItem )
ELSEIF IsObject(uItem) .AND. IsAccess(uItem, #ValueList ) .AND. IsString(
uItem:ValueList[1]:Value )
sValue := RTrim( uItem:ValueList[1]:Value )
ELSE
// No Textvalue found, (Icon)
sValue := "???"
ENDIF
AAdd(aHeadArray, sValue)
NEXT dwCount
sXLCol := ExcelColumn(dword(dwMaxCol))
oRange := oWorksheet:[Range, "A1",sXLCol+"1"]
oRange:Formula := aHeadArray
oRange:Interior:ColorIndex := 1
oRange:Interior:Pattern := 1
oRange:Font:ColorIndex := 2
oRange:Font:Bold := TRUE
aHeadArray := NULL_ARRAY
dwLine := 1 // So that we start on line 2 (Headings are on line 1)
SELF:Server:GoTop()
DO WHILE !SELF:Server:EoF
++dwLine
FOR dwCount := 1 UPTO dwMaxCol
uValue := SELF:GetOpenColumn(dwCount):Value
IF IsNil(uValue)
uValue := ""
ELSEIF Empty(uValue)
uValue := ""
ELSEIF IsString( uValue )
uValue := RTrim( uValue )
ELSEIF IsObject(uValue)
uValue := ""
ENDIF
AAdd(aLineArray, uValue)
NEXT dwCount
oRange := oWorksheet:[Range, "A"+NTrim(dwLine), sXLCol+NTrim(dwLine)]
oRange:Formula := aLineArray
aLineArray := {}
SELF:Server:Skip(1)
ENDDO
dwLine := dwLine + 2
// Now see if any columns have footers - if they do then put a sum()
// function into the spreadsheet
FOR dwCount := 1 UPTO dwMaxCol
uItem := SELF:GetOpenColumn(dwCount):Footer
// Here we need to check to see if the caption is made up from a compound
value
// or whether it is just a string. Compound values are used when sorting IS
allowed
// on the bBrowser columns.
sValue := ""
IF IsString(uItem)
IF !Empty(uItem)
sValue :=
"=Sum("+ExcelColumn(dword(dwCount))+"2:"+ExcelColumn(dword(dwCount))+NTrim(d
wLine-1)+")"
ENDIF
ENDIF
AAdd(aFootArray, sValue)
NEXT dwCount
oRange := oWorksheet:[Range, "A"+NTrim(dwLine),sXLCol+NTrim(dwLine)]
oRange:Formula := aFootArray
aFootArray := NULL_ARRAY
// Make Excel visible so they can save the sheet from Excel
oExcel:Visible := TRUE
:Server:ResetNotification()
SELF:Server:GoTop()
RECOVER
SELF:owner:Pointer:=oPointer
Messaggio(,"ERRORE EXPORT EXCEL")
//
***************************************************************************­
*
********
END SEQUENCE
//
***************************************************************************­
*
********
SELF:owner:Pointer:=oPointer
ErrorBlock( cbOldErrorHandler )
RETURN TRUE

vedi un po' se fa al caso tuo...
dovrebbe essere tutto molto semplice e leggibile
riceve 2 parametri
oServer = DBServer, così se è preventivamente filtrato ed ordinato...
vet_campi = quali campi esportare
(io preventivamente chiamo una funzione che fa scegliere all'utente quali 
campi esportare ed in che ordine)
ciao
Massimo Bighelli
ARCA Sistemi S.r.l.
============================================
METHOD Export2Excel(oServer,vet_campi) CLASS StandardShellWindow
LOCAL aTemp AS ARRAY
LOCAL numcampi AS DWORD
LOCAL i AS INT
LOCAL x AS INT
LOCAL xValue AS USUAL
LOCAL nHandle AS PTR
LOCAL cNomeDBF AS STRING
LOCAL oldCentury AS LOGIC
LOCAL oldCountry AS DWORD
Default(@vet_campi,{})   // se lo riceve DEVE essere un vettore in formato 
DBSTRUCT
                         // cioè: DBS_NAME DBS_TYPE DBS_LEN DBS_DEC 
DBS_ALIAS
// metto 4 cifre nell'anno
oldCentury := SetCentury(TRUE)
oldCountry := SetDateCountry(ANSI)
xValue := 0
cNomeDBF := oServer:name
IF ALen(vet_campi) > 0
 aTemp := vet_campi
ELSE
 aTemp := oServer:DBSTRUCT
ENDIF
numcampi := ALen(aTemp)
oServer:GOTOP()
// elimino eventuale file temporaneo con quel nome in locale
FErase(g_perc_loca+cNomeDBF+'.Xls')
// creo file script VBS e comincio a scriverlo
nHandle := FCreate(g_perc_loca+cNomeDBF+".Vbs",0)
FWrite(nHandle,'Dim oExcel'+CRLF)
FWrite(nHandle,'Set oExcel = 
WScript.CreateObject("Excel.Application")'+CRLF)
FWrite(nHandle,'oExcel.Visible = TRUE'+CRLF)
FWrite(nHandle,'oExcel.DisplayFullScreen = FALSE'+CRLF)
FWrite(nHandle,'oExcel.WorkBooks.Add'+CRLF)
FWrite(nHandle,''+CRLF)
// definizione delle colonne Excel
//********************************
// larghezza
FOR i := 1 UPTO numcampi
   FWrite(nHandle,'oExcel.Columns('+NTrim(i)+').ColumnWidth 
='+NTrim(aTemp[i,3]+2)+CRLF)
NEXT
FWrite(nHandle,''+CRLF)
x := 1
// testata colonna in riga 1
FOR i := 1 UPTO numcampi
 FWrite(nHandle,'oExcel.Cells(1,'+NTrim(i)+').Value ="'+aTemp[i,1]+'"'+CRLF)
NEXT
FWrite(nHandle,''+CRLF)
DO WHILE !oServer:EOF
 x++
 FOR i := 1 UPTO numcampi
  xValue := oServer:FIELDGET(aTemp[i,1]) //oServer:FIELDGET(i)
  IF ValType(xValue) == 'C'
   IF ["] $ xValue
    xValue := StrTran(xvalue,["],[ ])
   ENDIF
   IF Left(xValue,1) == '0' .or. Val(Left(xValue,1)) > 0
    xValue := [']+xValue
   ENDIF
   FWrite(nHandle,'oExcel.Cells('+NTrim(x)+','+NTrim(i)+').Value 
="'+Trim(xValue)+'"'+CRLF)
  ELSEIF ValType(xValue) == 'N'
   FWrite(nHandle,'oExcel.Cells('+NTrim(x)+','+NTrim(i)+').Value 
='+NTrim(xValue)+CRLF)
  ELSEIF ValType(xValue) == 'D'
   IF Empty(xValue)
    FWrite(nHandle,'oExcel.Cells('+NTrim(x)+','+NTrim(i)+').Value =""'+CRLF)
   ELSE
    FWrite(nHandle,'oExcel.Cells('+NTrim(x)+','+NTrim(i)+').Value 
="'+DToC(xValue)+'"'+CRLF)
   ENDIF
  ELSE
   FWrite(nHandle,'oExcel.Cells('+NTrim(x)+','+NTrim(i)+').Value =""'+CRLF)
  ENDIF
   NEXT
   FWrite(nHandle,''+CRLF)
   oServer:SKIP()
ENDDO
FWrite(nHandle,''+CRLF)
FWrite(nHandle,'oExcel.AlertBeforeOverwriting = FALSE'+CRLF)
FWrite(nHandle,'oExcel.ActiveWorkBook.SaveAs("'+g_perc_loca+cNomeDBF+'.xls")'+CRLF)
FWrite(nHandle,'oExcel.Quit()'+CRLF)
FClose(nHandle)
// rimetto Century
SetCentury(oldCentury)
SetDateCountry(oldCountry)
// lancio Excel con il suo script
//-------------------------------
ShellExecute(NULL,String2Psz("Open"),String2Psz(g_perc_loca+cNomeDBF+".Vbs"),String2Psz(''),String2Psz(g_perc_loca),SW_NORMAL)
RETURN

 ha scritto nel messaggio 
news:49c4bb35$0$1108$4faf...@reader3.news.tin.it...
