In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

ToExcel

Xailer professional forum in English
Responder
pjmfelix
Mensajes: 61
Registrado: Jue Abr 27, 2006 1:23 pm

ToExcel

Mensaje por pjmfelix »

Hi,
I Have a old function that work with DBfDataSet, now I change to work With
SQLTable, but I can not show the fileds, any help.
My Old function:
ToExcel( ::oDataSet, ;
"Listagem de ...", ;
{"Codigo", "Rua", "Troco", "Localidade", "Concelho"}, ;
{"Codigo", "Rua", "Troco", "Localidade", "Loc_Conc"})
//---------------------------------------------------------- --------------------
Function ToExcel( oDataSet, cTitle, aHeader, aField )
Local oReport
Local nFor
Local cHeader
Local cField
REPORT oReport ;
TITLE cTitle
oReport:oDataSet := oDataSet
For nFor := 1 To Len(aField)
cHeader := '"' + aHeader[nFor] + '"'
cField := aField[nFor]
COLUMN OF oReport ;
Title &cHeader ;
DATA &cField
Next
oReport:ToExcel()
Return .T.
//---------------------------------------------------------- --------------------
My new function:
::oSQLTable1:oDataSource := AppData:oAdoDataSource1
::oSQLTable1:cTableName := "AGnPst"
::oSQLTable1:lOpen := .T.
ToExcel( ::oSQLTable1, ;
"Listagem de ...", ;
{"Codigo", "Rua", "Troco", "Localidade", "Concelho"}, ;
{::oSQLTable1:FieldName(1), ::oSQLTable1:FieldName(2),
::oSQLTable1:FieldName(3), ::oSQLTable1:FieldName(4),
::oSQLTable1:FieldName(5)})
//---------------------------------------------------------- --------------------
Function ToExcel( oDataSet, cTitle, aHeader, aField )
Local oReport
Local nFor
Local cHeader
Local cField
REPORT oReport ;
TITLE cTitle
oReport:oDataSet := oDataSet
For nFor := 1 To Len(aField)
cHeader := "'" + aHeader[nFor] + "'"
cField := aField[nFor]
COLUMN OF oReport ;
Title &cHeader ;
DATA cField
Next
oReport:ToExcel()
Return .T.
//---------------------------------------------------------- --------------------
Best Regards.
Paulo Félix
SHI, Lda.
Rua Garcia de Orta, 48 - 3.º C
Damaia
2720-253 Amadora
Tel.: (351)214 768 098
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9441
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

ToExcel

Mensaje por ignacio »

Paulo,
If the array aFields is a list of field names, that is the problem. On DBFs, the RDD creates special FIELD variables for the active area. I suggest yo use the instruction FOR EACH with a unique two dimension array instead of a standard FOR. That way you will not need to do any macro.
For EACH Field IN aFields
COLUMN OF oReport ;
Title Field[ 1 ] ;
DATA oDataset:FieldGet( oDataset:FieldPos( Field[ 2 ] ) )
Next
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
pjmfelix
Mensajes: 61
Registrado: Jue Abr 27, 2006 1:23 pm

ToExcel

Mensaje por pjmfelix »

Hi Ignacio,
I have the problem in oSQLTable, in oDBFDataSet work fine !!!
Regards.
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> escreveu na
mensagem news:4c18faed$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Paulo,
> If the array aFields is a list of field names, that is the
> problem. On DBFs, the RDD creates special FIELD variables
> for the active area. I suggest yo use the instruction FOR
> EACH with a unique two dimension array instead of a
> standard FOR. That way you will not need to do any macro.
>
> For EACH Field IN aFields
>
> COLUMN OF oReport ;
> Title Field[ 1 ] ;
> DATA oDataset:FieldGet( oDataset:FieldPos( Field[ 2 ] )
> )
>
> Next
>
> Regards, --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9441
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

ToExcel

Mensaje por ignacio »

Paulo,
I knew that. Please send a sample and the content of aFields.
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
"Paulo Félix" <pjmfelix@shi.pt> escribió en el mensaje de
noticias:[email=4c1a2eee@svctag-j7w3v3j....]4c1a2eee@svctag-j7w3v3j....[/email]
> Hi Ignacio,
>
> I have the problem in oSQLTable, in oDBFDataSet work fine !!!
>
> Regards.
>
>
>
>
> "Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> escreveu
> na mensagem news:4c18faed$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
>> Paulo,
>> If the array aFields is a list of field names, that is the
>> problem. On DBFs, the RDD creates special FIELD variables
>> for the active area. I suggest yo use the instruction FOR
>> EACH with a unique two dimension array instead of a
>> standard FOR. That way you will not need to do any macro.
>>
>> For EACH Field IN aFields
>>
>> COLUMN OF oReport ;
>> Title Field[ 1 ] ;
>> DATA oDataset:FieldGet( oDataset:FieldPos( Field[ 2 ] )
>> )
>>
>> Next
>>
>> Regards, --
>> Ignacio Ortiz de Zúñiga
>> [Equipo de Xailer/Xailer team]
>> http://www.xailer.com
>> http://www.xailer.info
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder