Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exporting To Excel
Message
From
19/05/2005 14:54:50
 
 
To
19/05/2005 14:45:13
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Network:
Windows NT
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01015815
Message ID:
01015963
Views:
20
Cool, thanks for the ideas Dragan!


>>Can you step through the table and copy each record? Something like:
>>
>>SET SAFETY OFF
>>CREATE TABLE foxtest (ca c(10), cb c(10), cc c(10))
>>PRIVATE icounter
>>FOR icounter = 1 TO 1000
>>    sele foxtest
>>    APPEND BLANK
>>    REPLACE ca WITH "a" + ALLTRIM(STR(icounter))
>>    REPLACE cb WITH "b" + ALLTRIM(STR(icounter))
>>    REPLACE cc WITH "c" + alltrim(STR(icounter))
>>    icounter = icounter + 1
>>ENDFOR
>>
>>RELEASE oExcel
>>lcXLSFile = 'foxtest'
>>lcXLSFile = ForceExt(lcXLSFile, "XLS")
>>
>>lcRange = "a1:c1000"
>>oExcel = CREATEOBJECT("excel.application")
>>WITH oExcel
>>   .WorkBooks.add()
>>   WITH .ActiveWorkbook.ActiveSheet.RANGE(lcRange)
>
>Here's my speed tip - just today it took just a few seconds to insert 15300 rows into an Excel sheet. I'm assuming a one-line range is selected, and then I expand it as needed.
>
>
	_vfp.DataToClip(,,3)
>	* remove first line from clipboard, contains column names
>	c=_cliptext
>	_cliptext=Strtran(_cliptext, Mline(_cliptext,1)+chr(13),"")
>
>	If RECCOUNT() > 1
>		oExcel.Application.CutCopyMode = .t.
>		oRng = oExcel.Range(oExcel.Cells(.Row + 1, 1), oExcel.Cells(.Row + reccount() - 1, 1))
>		oRng.EntireRow.Insert
>	ENDIF
>	oRng.select()
>	oExcel.selection.PasteSpecial()
>	_cliptext=c
>
>
>And that's it. I may have been off by one here, as I had to rename a few variables to fit the names in the example, and remove some framework related code, but with a couple of tweaks this should work - and it's quite a bit faster than filling cells one by one.
>
>
>   ENDWITH
>>   .save(lcXLSFile)
>>ENDWITH
>>
>>USE IN foxtest
>>oExcel.quit()
>>
>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform