Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel to recognize FoxPro memo fields?
Message
De
20/07/2000 04:11:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00393509
Message ID:
00394785
Vues:
10
>Is there any way to get Excel to open a FoxPro table *.dbf? Access can open a *.dbf FoxPro table, but can Excel?
>
>I run VFP 6.0 and am trying to import my memo fields into Excel. I have had luck getting them into excel by opening my FoxPro table in Access, and changing the field definition from Memo to text. Then saving as some other file format and opening in Excel. Is there any way to cut out the Access step and go straight from VFP tables to Excel and keep my memo fields?
>
>Excel has a dBase *.dbf option, but it does not keep my VFP 6.0 memo fields.
>
>Thanks
>
>Brenda


Brenda,
As your thread gets long I thought might not be solved already. If did discard :
Use testmemo && Samples employee as test table 
=Table2ClipBoard()
#include "xlconstants.h"
oExcel = createobject("Excel.Application")
With oExcel
   .Workbooks.Add
   .visible = .t.
   With .ActiveWorkbook.ActiveSheet
      .Paste
      .Range('A1').CurrentRegion.Replace("PMARK",chr(10),xlPart,xlByRows, .F.)
   Endwith
   With .Selection
      .ColumnWidth = 50 && Increase width for memo
      .HorizontalAlignment = xlGeneral
      .VerticalAlignment = xlTop
      .WrapText = .T.
   Endwith
Endwith


Function Table2ClipBoard
lcTempFileName = "X"+sys(2015)+".tmp"
handle = fcreate(lcTempFileName)   && Create a temp file
#Define TABULATE chr(9)
#Define NL chr(13)

For ix = 1 to fcount()
   =fwrite(handle, field(ix))
   If ix < fcount()
      =fwrite(handle, TABULATE)
   Endif
Endfor
=fwrite(handle, NL)
Scan      && Start scan..endscan
   For ix = 1 to fcount()   && Write field values
      =fwrite(handle, typeconvert(ix) )
      If ix < fcount()
         =fwrite(handle, TABULATE)
      Endif
   Endfor
   =fwrite(handle, NL)
Endscan
lnSize=fseek(handle,0,2)
=fseek(handle,0,0)
_Cliptext = fread(handle, lnSize)  && Read file to clipboard
=fclose(handle)
Erase (lcTempFileName)

Function typeconvert
Lparameters tnField
lcType = type(field(ix))
If lcType = "G"
   lcField = field(ix)
   Return transform(&lcField)
Endif
luValue = eval(field(ix))
Do case
Case lcType = "D"
   lcValue = dtoc(luValue)
Case lcType = "T"
   lcValue = ttoc(luValue)
Case lcType $ "NY"
   lcValue = padl(luValue,20," ")
Case lcType = "L"
   lcValue = iif(luValue,"Yes","No")
Case lcType $ "M" && Replace paragraph marks with "PMARK"
   lcValue = strtran(luValue, chr(13)+chr(10), "PMARK")
Case lcType $ "C"
   lcValue = luValue
Otherwise
   lcValue = ""
Endcase
Return alltrim(lcValue)
Pls keep in mind that copying to clipboard won't work with large tables and should be divided.
Cetin
Ç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