Jaime Vasquez wrote:
> Ricardo Aráoz wrote:
>> Jaime, it works! And it solves my problem.
>> Only glitch is that the second 'CopyFromRecordset(loRs, 150) && copy
>> next 150' does not copy the next 150 but copies the first 150 records
>> again. Not a problem, I can copy my chunks of records to a cursor and
>> then do a cursor at a time (rs.Delete(150) does not work either).
>>
>> Anyway if you can see a more elegant solution I'll appreciate it.
>> Thanks for your help.
>>
>> Here is my test code :
>> ---------------------------------------------------
>> loWorkBook = loExcel.WorkBooks.Add
>> loWorkBook.ActiveSheet.name = 'PrimeraHoja'
>>
>> loWorkBook.Worksheets("PrimeraHoja").Range('a2').CopyFromRecordSet(lors,20)
>>
>> loWorkBook.WorkSheets.Add(, loWorkBook.ActiveSheet)
>> loWorkBook.ActiveSheet.Name = 'SegundaHoja'
>>
>> loWorkBook.WorkSheets("SegundaHoja").Range('a2').CopyFromRecordSet(lors,20)
>>
>> loWorkBook.Application.Visible = .T.
>> ----------------------------------------------------
>>
>> and the same first 20 records are copied in both pages.
>> So I do :
>> -----------------------------------------------------
>> go top in MyCursor
>> lors = dbf2rs('MyCursor', 'Next 20')
>>
>> loWorkBook = loExcel.WorkBooks.Add
>> loWorkBook.ActiveSheet.name = 'PrimeraHoja'
>>
>> loWorkBook.Worksheets("PrimeraHoja").Range('a2').CopyFromRecordSet(lors,20)
>>
>> go 21 in MyCursor
>> lors = dbf2rs('MyCursor', 'Next 20')
>>
>> loWorkBook.WorkSheets.Add(, loWorkBook.ActiveSheet)
>> loWorkBook.ActiveSheet.Name = 'SegundaHoja'
>>
>> loWorkBook.WorkSheets("SegundaHoja").Range('a2').CopyFromRecordSet(lors,20)
>>
>> loWorkBook.Application.Visible = .T.
>> -----------------------------------------------------
>>
>
> Ricardo,
>
> This behavior is because the recordset is a "client recordset", you
> can't delete records, and everytime you copy records it will start from
> the beginning.
>
> With a server recordset you can use the method I suggested of copy
> records by chunks, or delete them.
>
> You can create a server recordset converting your cursor to a temporary
> phisical table and next read it with ADO.
>
> I thing the solution you found is the best, create a recordset with the
> number of records you want to copy in every page.
>
> I just have 2 observations:
> If the recordset has the number of records you want, there's no need for
> the sencond parameter in copyfromrecordset method.
>
> The copy will be a bit faster if you set excel visible = .t. before copy
> the recordset.
>
>
>
> HTH
>
>
>
> Saludos,
> Jaime Vasquez
>
>
Muchas gracias Jaime. Me ha venido muy bien tu ayuda.
Saludos.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.