DDL and Excel continued (None Specified)
At 09 NOV 1999 01:33:55PM Blair Massey wrote:
Hello OI Commnity:
I have a routine which takes data from the Temp table and exports it to Excel. The program works fine with up to 400 rows of information. However, with 3000+ rows it fails. My logic may be flawed, or the method, or Heaven forbid, OI. Basically I write data into to an editbox then export it a cell at a time. Can someone point out the error of my code or suggest a better method? Here's the code:
For r=1 to nrows
Read row from tempvar, r ThenFor c=1 to CntFldsx=Set_Property('BUYEXPORT.DDE','TEXT', row)string=R' :r: 'C' : cstatus=Set_Property('BUYEXPORT.DDE', 'DDEITEM', string)status=Set_Property('BUYEXPORT.DDE', 'DDELINK', 'AUTO')status=Set_Property('BUYEXPORT.DDE', 'DDEDATA', row)If status ElseMsg(@window, MsgUp)error=Export failed. Make sure Excel is open' : crlf$error := 'and the file ' : excel: ' is displayed.'status=Set_Property('BUYEXPORT.DDE', 'DDELINK', 'OFF')ReturnEndnext cEnd Elseerror=Error reading TEMP'Msg(@window, MsgUp)ReturnEndYield()While Msg(@window, MsgUp, r, MSGINSTUPDATE$)Yield()next r
At 11 NOV 1999 04:45AM Oystein Reigem wrote:
Blair,
Your code looks fine to these untrained eyes. But perhaps each request reduces available resources? Can you try to export in larger chunks? Isn't it possible to set a whole range and not just a cell (DDEITEM)? You could e.g take one whole row at a time.
- Oystein -
At 11 NOV 1999 05:10AM Oystein Reigem wrote:
Blair,
Does it make any difference if you let Excel do a save now and then? Saving - see http://www.revelation.com/THEWORKS/OIdiscuss.nsf/ef8405490de3608f85256700005245e4/40A2B58B6CFC8291852568230078C617?OpenDocument.
- Oystein -
At 11 NOV 1999 09:27AM Arjun Revelation wrote:
Blair,
I think Oystein is right, the reason why the utility breaks down is most probably because of a memory leak taking place as you are exporting to one cell at a time.
Another thing is that you may want to close the connection each time a part of data is transfered to EXCEL, I would recommend adding the
syntax…..'DDELINK', OFF, much earlier in the code. I have added it below, where I think it should work:
For r=1 to nrows
Read row from tempvar, r Then
For c=1 to CntFlds
x=Set_Property('BUYEXPORT.DDE','TEXT', row)
string=R' :r: 'C' : c
status=Set_Property('BUYEXPORT.DDE', 'DDEITEM', string)
status=Set_Property('BUYEXPORT.DDE', 'DDELINK', 'AUTO')
status=Set_Property('BUYEXPORT.DDE', 'DDEDATA', row)
status=Set_Property('BUYEXPORT.DDE', 'DDELINK', 'OFF')
If status Else
Msg(@window, MsgUp)
error=Export failed. Make sure Excel is open' : crlf$
error := 'and the file ' : excel: ' is displayed.'
At 11 NOV 1999 08:45PM Blair Massey wrote:
Thanks for reply Oystein,
I'm have no idea of how to modify the code to export a row at a time. The way I've coded it is CPU intensive and very slow, which can
be a factor when you want to export 800 row with 8 columns.
Do you know how it can be done a row at a time?
At 11 NOV 1999 08:47PM Blair Massey wrote:
Hey Arjun!
I spoke with Mike Ruane. He said to set it to off after 300 rows or so. That didn't work at my installed site. Perhaps closing link after each cell would work, but surely there is a faster way to get this job done.
At 11 NOV 1999 08:48PM Blair Massey wrote:
I'll give it a shot!
At 11 NOV 1999 08:53PM Blair Massey wrote:
Arjun, do you know how the code could be modified to export a row at at time?
At 12 NOV 1999 04:10AM Oystein Reigem wrote:
Blair,
The docs say you can set the values of a whole range of Excel cells, and by experimenting a little I've found out exactly how. E.g with DDEITEM equal to 'R1C1:R1C3' you can set the values of the first three cells of the first row. The values (DDEDATA) must be delimited with Char(9)=Tab (convert @FM to Char(9) in Row). You can also set the values of a rectangle of cells. E.g with DDEITEM=R1C1:R2C3' you can set the values of cells 1-3 of row 1-2. In the values you must tyhen have CrLf$ between each row.
Btw - are you sure you should set both TEXT and DDEDATA? (Probably not important.)
- Oystein -
At 12 NOV 1999 09:48AM Blair Massey wrote:
Good morning Arjun,
I was able to try the code you suggested this morning. It works
much better and is suprisingly fast.
Thanks!