Página 1 de 1

ToExcel

Publicado: Mié Jun 16, 2010 6:04 pm
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

ToExcel

Publicado: Mié Jun 16, 2010 6:25 pm
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,

ToExcel

Publicado: Jue Jun 17, 2010 4:19 pm
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

ToExcel

Publicado: Jue Jun 17, 2010 7:10 pm
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
>