Página 1 de 1

TDBBrowse to Excel

Publicado: Mié Ene 05, 2011 10:59 am
por Maarten Roos
Hello.
Is it possible to export data from TDDBrowse, including the OnGetData values, to Excel?
If yes, how to do? I have no idea how to export the values from the OnGetData?

TDBBrowse to Excel

Publicado: Mié Ene 05, 2011 11:51 am
por ignacio
Maarten,
Try to use the REPORT engine included with Xailer. Two tips:
1) Set the dataset with the clause REPORT oReport .... DATASET oMyDataset
2) Send the report to Excel with oReport:ToExcel( cFile )
Note: Excel should be installed on the client PC.
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
http://www.xailer.com/forum
http://www.xailer.com/dokuwiki
"Maarten Roos" escribió en el mensaje de
noticias:4d244111$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
Hello.
Is it possible to export data from TDDBrowse, including the
OnGetData values, to Excel?
If yes, how to do? I have no idea how to export the values
from the OnGetData?

TDBBrowse to Excel

Publicado: Mié Ene 05, 2011 12:23 pm
por Maarten Roos
I have managed to export a dataset to Excel... but how do I use values from other datasets to use full name instead of code?
The dataset has relations to other datasets, but no idea to get them when needed?

METHOD ExportToExcel() CLASS frmNotesSearch
LOCAL aHeader := {}, aField := {}, x := 1, Ohulp := ::oBrw:aCols
for x=1 to len(::oBrw:aCols)
if ::oBrw:aCols[x]:lVisible
if Upper(::oBrw:aCols[x]:oDataField:ClassName())==Upper("TDataField")
AADD(aHeader,::oBrw:aCols[x]:cHeader)
AADD(aField,::oBrw:aCols[x]:oDataField:cDbfName)
endif
endif
next
if len(aHeader)<>0
ExportToExcel(::oDbfTN, "Telephone Notes", aHeader, aField)
else
MsgInfo("Nothing to export...")
endif
RETURN NIL


Function ExportToExcel(oDataSet, cTitle, aHeader, aField)
Local oReport, x, cHeader, cField
oDataSet:Select()
REPORT oReport ;
TITLE cTitle
oReport:oDataSet = oDataSet
For x := 1 To Len(aField)
cHeader := '"' + aHeader[x] + '"'
cField := aField[x]
COLUMN OF oReport ;
Title &cHeader ;
DATA &cField
Next
oReport:cJobName := "Excel Converter"
oReport:ToExcel()
RETURN NIL

But this will use only one dataset (oDbfTN)
I like to use the same data as shown in the browser (oBrw) to be exported to Excel.
So this...

Gives me now...


TDBBrowse to Excel

Publicado: Mié Ene 05, 2011 4:08 pm
por ignacio
Maarten,
COLUMN ... OF oReport ;
TITLE ... ;
DATA MyRelation( oDatasetMain, oDataSetRel )
....
STATIC FUNCTION MyRelation( oMain, oRel )
oRel:Locate( <expression involving oMain > )
RETURN oRel:MyRelField
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
http://www.xailer.com/forum
http://www.xailer.com/dokuwiki
"Maarten Roos" escribió en el mensaje de
noticias:4d2454c7$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
I have managed to export a dataset to Excel... but how do I
use values from other datasets to explain full name instead
of code?
The dataset has relations to other datasets, but no idea to
get them when needed?
METHOD ExportToExcel() CLASS frmNotesSearch
LOCAL aHeader := {}, aField := {}, x := 1, Ohulp :=
::oBrw:aCols
for x=1 to len(::oBrw:aCols)
if ::oBrw:aCols[x]:lVisible
if
Upper(::oBrw:aCols[x]:oDataField:ClassName())==Upper("TDataField ")
AADD(aHeader,::oBrw:aCols[x]:cHeader)
AADD(aField,::oBrw:aCols[x]:oDataField:cDbfName)
endif
endif
next
if len(aHeader)<>0
ExportToExcel(::oDbfTN, "Telephone Notes", aHeader,
aField)
else
MsgInfo("Nothing to export...")
endif
RETURN NIL
Function ExportToExcel(oDataSet, cTitle, aHeader, aField)
Local oReport, x, cHeader, cField
oDataSet:Select()
REPORT oReport ;
TITLE cTitle
oReport:oDataSet = oDataSet
For x := 1 To Len(aField)
cHeader := '"' + aHeader[x] + '"'
cField := aField[x]
COLUMN OF oReport ;
Title &cHeader ;
DATA &cField
Next
oReport:cJobName := "Excel Converter"
oReport:ToExcel()
RETURN NIL
But this will use only one dataset (oDbfTN)
I like to use the same data as shown in the browser (oBrw)
to be exported to Excel.
So this...
Give me now...

TDBBrowse to Excel

Publicado: Jue Ene 06, 2011 5:08 pm
por Maarten Roos
Thx, but wasn't the solution I was looking for... but it gave me a brainwave to the solution.