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:14:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/05/2009 04:10:04
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
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:
01399559
Vues:
50
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.

.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.

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).
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
>>
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform