Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Spreadsheet functions
Message
From
17/10/2006 12:48:27
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01162592
Message ID:
01162635
Views:
15
>>>>>Hi guys
>>>>>
>>>>>I need to do 2 things:
>>>>>
>>>>>1) from my current cursor I need to produce 3 worksheets in the same book, each being more of a summary of the previous.
>>>>>i.e. I have a cursor with all the data, cut down to sub-totals and totals, and cut down to just totals (and a grand total for each, of course). I know how to reduce the cursor for each sheet, but how to include each one in the same book.
>>>>>
>>>>>2) VFP currently does the above totals/sub-totals but my users would prefer the SUM() function, as they may need to insewrt extra rows in the s/s/ afterwards. I imagine this is a bit tricky.
>>>>>
>>>>>A tall order?
>>>>>
>>>>>Thanks for listening
>>>>>
>>>>>Terry
>>>>
>>>>Terry,
>>>>
>>>>For the first part:
>>>>
>>>>ox = CREATEOBJECT('Excel.Application')
>>>>ob = ox.Workbooks.Open('YourWorkbook.xls')
>>>>os1 = ob.Worksheets(1)
>>>>os2 = ob.Worksheets(2)
>>>>os3 = ob.Worksheets(3)
>>>>
>>>>Regards,
>>>
>>>Thanks Jim
>>>
>>>I can see that that references 3 worksheets within a book, but how to export my respective cursors into trhe 3 sheets?
>>>
>>>Terry
>>
>>Terry,
>>
>>Something like this. Not tested and it would quicker using field names, etc.
>>
>>oRange = os1.Range('A1')
>>SELECT Cursor1
>>WITH oRange
>>   SCAN
>>      FOR nPtr = 1 to FCOUNT('Cursor1')
>>         .OFFSET(nPtr-1).Value = EVALUATE(FIELD(nPtr))
>>      ENDFOR
>>      oRange = oRange.OFFSET(0,1)
>>   ENDSCAN
>>ENDWITH
>>
>>Repeat with os2 and Cursor2, etc.
>>Regards,
>
>I think I see what you mean:
>
>You make like a range of fields * recs in the cursor and that's kinda "pasted" into each sheet????
>This isn't doing the usual EXPORT ... XLS thing which creates a sheet within a workbook, but sort of by-passses this???
>That was the obstacle I found.
>
>Thanks
>
>Terry

Right, its just Excel automation. Not as fast as EXPORT or COPY TO but it gives you a lot more control on where things go, formatting if you want it, etc. And, unless you're dealing with huge data sets, you shouldn't find the diffence in time significant.

Glad if it helps,
Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform