Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exported date to Excel won't format as date
Message
De
13/05/2009 05:34:08
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
13/05/2009 05:14:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01399348
Message ID:
01399562
Vues:
47
>Agnes,
>.Value = getArrayRef("myArray")
>
>is one the fastest methods I have ever seen (I timed them all - 200K+ rows in multiple sheets). However, with array approach I found that excel may choke (depending on excel version, RAM ...), it was hard to find the rowcount that you can send at once.

We never used Excel 2K7 to its limits (rows) With 2K3 we calculate the number of rows on Sheet can receive (there may be uper and lower limits, we fill XLT based)
There was never a failure. Our RAM is normaly 4G, We supported only Excel W2K3 and W2K7 yet. (We do deeper stuff with automation, customer restricts its comp to this so no need for testing other versions)

BTW how would one linit the connection to a range?

What we found is trouble with date values. Some user enters 1.4.0083 and this brokes the array method. It stops at the cell with this date.

>.QueryTables.Add(...) is nice but if you save the sheet and move to another PC (no connection to data IOW) then reopening is slow (waits for timing out trying to locate and connect to source). Otherwise nice it loads and updates from source.

I read that CopyFromRecordSet will insert values only. No connection will remain in the XLS.

>From a cursor it works by copying out to tables (you are passing connection and SQL). In case of free tables you don't have a problem other than fieldname (and that is not a problem because you are free to write whatever you want for headers).

No idea how this looks like. Can you provide a code snippet?

Thanks Agnes

>Cetin
>
>
>
>>Hi Cetin,
>>
>>I'm blind on the Adodb eye
>>
>>Do you have compared the Adodb solution with the ".Value = Array" solution?
>>What I see on the first is that strings are digits only will be formated as text. Nice
>>
>>Any other problems?
>>
>>How does this work with a Cursor (not bound to a DBC)?
>>
>>Agnes
>>>>...
>>>
>>>Instead of export use VFPOLEDB to 'export' the data and you wouldn't have such problem. ie:
>>>
>>>
>>>#Define xlTop -4160
>>>Local oExcel
>>>oExcel = Createobject("Excel.Application")
>>>With oExcel
>>>  .WorkBooks.Add
>>>  .Visible = .T.
>>>  VFP2Excel(_samples+'data\testdata.dbc',;
>>>    'select emp_id,first_name,last_name,'+;
>>>    'cast(EVL(birth_date,null) as d) as birth_date,'+;
>>>    'CAST(CHRTRAN(notes,CHR(13),"") as M) as Notes from employee',;
>>>    .ActiveWorkBook.ActiveSheet.Range('A1'))
>>>    
>>>  * This part is cosmetic  
>>>  With .ActiveWorkBook.ActiveSheet
>>>    .UsedRange.VerticalAlignment = xlTop && set all to top
>>>    With .Columns(5)
>>>      .ColumnWidth = 80 && 80 chars width
>>>      .WrapText = .T.
>>>    Endwith
>>>    .UsedRange.Columns.AutoFit
>>>    .UsedRange.Rows.AutoFit
>>>  Endwith
>>>Endwith
>>>
>>>Function VFP2Excel
>>>  Lparameters tcDataSource, tcSQL, toRange
>>>  Local loConn As AdoDB.Connection, ;
>>>    loRS As AdoDB.Recordset,;
>>>    ix
>>>  loConn = Createobject("Adodb.connection")
>>>  loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource
>>>  loConn.Open()
>>>  loRS = loConn.Execute(m.tcSQL)
>>>
>>>  For ix=1 To loRS.Fields.Count
>>>    toRange.Offset(0,m.ix-1).Value = Proper(loRS.Fields(m.ix-1).Name)
>>>    toRange.Offset(0,m.ix-1).Font.Bold = .T.
>>>  Endfor
>>>  toRange.Offset(1,0).CopyFromRecordSet( loRS )
>>>  loRS.Close
>>>  loConn.Close
>>>Endfunc
>>>
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform