Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OK, OK, I'm also exporting to Excel
Message
De
04/06/1999 03:36:35
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00225494
Message ID:
00226376
Vues:
28
>Dragan,
>
>I'd talk directly to the Excel cells, it's quite easy.
>
>If you want to stay _cliptext route, you can always strip off the first line:
>
>_cliptext = substr( _cliptext, at( chr(13), _cliptext ) + 1 )
>
>>I'm developing an app where the results should be appended to an existing Excel table. I've tried the _vfp.datatoclip() and it works perfectly, except for a couple of glitches:
>>

(This goes to Bruce, Rox and Paul Vlad as well)

Of course I'm doing the OLE - but it was painfully slow to address dozens of rows, so I wanted to prepare everything in Fox, and move all the data with one command - and I finally did it. I needed to append a bunch of records below the bottom rows of a worksheet, and here's how I did it:
 select * from sati where &lcCondition;
	into curs zz
set mark to "-"
?date()
set date dmy
_outtext=""
#define	tab	chr(9)
#define	cr	chr(13)
set mark to "-"
set point to
set separ to
scan
	_outtext=_outtext+ trim(radnik) +tab
	_outtext=_outtext+ trim(r_n) +tab
	_outtext=_outtext+ dtoc(datum) +tab
	_outtext=_outtext+ str(od_sati, 5,2) +tab
	_outtext=_outtext+ str(do_sati, 5,2) +tab
	_outtext=_outtext+ alltr(str(user, 5)) +tab
	_outtext=_outtext+ " " +tab
	_outtext=_outtext+ alltr(projekt) +tab
	_outtext=_outtext+ " " +tab
	_outtext=_outtext+ " " +tab		&& these fields need to contain formulae from previous rows
	_outtext=_outtext+ " " +tab
	_outtext=_outtext+ " " +tab
	_outtext=_outtext+ trim(status)+tab
	_outtext=_outtext+ mline(napomena,1)+cr
ends
_cliptext=_outtext
x=getfile("xls")
public oExcel
oExcel=createobject("Excel.Application")
oExcel.Workbooks.open(x)
with oExcel
	.visible=.t.
	.workbooks(1).activate
	.range("B1").select
	.selection.end(-4121).select
	.activewindow.activecell.Offset(1, 0).Activate
	.ActiveSheet.Paste
	oexcel.activeworkbook.close(1)
endwith
release oexcel
It works just fine, and (except for an eternity and a half, which is the time for Excel to load) quick. Now the next trouble is that I don't know where I am. I'd like to copy the formulae from previous rows in certain columns, and I've recorded the macro to do it, and it'd all be fine - but how do I get the row and column position where I was before I pasted? All the ranges in the macro are welded in. After several hours of wading through the object browser and Excel VBA help, I feel somewhat dizzy and don't know where next to look. I felt almost lucky that the power went out (and more lucky now when I discovered I don't have to reinstall anything :), so I could delegate the problem to the next day.

So, the remaining question is: where am I? How do I retrieve the current row and column so I can use it in Fox to navigate further?

To Rox: paste special didn't perform as expected with either format. Format 3 and simple paste would be the way to go, but I had to drop that, because fields like user and projekt have to be trimmed to be used as a parameter for the VLookUp() function in Excel, and that's the reason I switched to _cliptext + OLE Auto. Another reason is the memo field - I needed the first line of it, not the word "Memo" which DataToClip() sends.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform