Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem opening a csv file
Message
De
03/08/2001 12:11:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/08/2001 11:43:25
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00539374
Message ID:
00539459
Vues:
30
This message has been marked as the solution to the initial question of the thread.
Isaac,
Just renaming doesn't make it CSV. A CSV is a comma delimited (text qualifier doublequotes) file where first line contains headers.
* CSV way
Use customer
Copy to customer type CSV && Extension by default is csv
oExcel = createobject('Excel.Application')
With oExcel
  .Workbooks.Open(sys(5)+curdir()+'customer.csv')
  .visible = .t.
Endwith

*OpenText way
#Define xlDelimited 1
#Define xlTextQualifierSingleQuote 2
Use customer
Copy to customer type delimited with "|" && Customer has single quote in fields
Strtofile(chrtran(FileToStr('customer.txt'),"'",""),"customer.txt") && Remove single quotes
Strtofile(chrtran(FileToStr('customer.txt'),"|","'"),"customer.txt") && TextQualifier single quote
oExcel = createobject('Excel.Application')
With oExcel
  .Workbooks.OpenText(;
    sys(5)+curdir()+'customer.txt',,,xlDelimited, xlTextQualifierSingleQuote,,,,.T.)
  .visible = .t.
Endwith
Cetin

>Thanks for the suggestion, however, I don't quite understand.
>I did try renaming the file to a .csv and I still have the same issue. The fields in the file are delimited with a single quote. When the file is opened in excel the columns still have the single quote around them.
>
>If I open the file (a txt) manually in excel and go thru the options presented selecting the delimited option of single quotes the file opened correctly. I tried recording this as a macro and looking at what it does which is how I got to the options I did try. I'll keep searching.
>
>Regards,
>-Isaac
>
>>>Hello,
>>>
>>>I have a comma separated file with single quote delimiters that I am trying to open in Excel 2000 using VFP 6 automation. I can't seem to figure out the parameter or its position to tell excel that the file used the single quote delimeters. Does anyone know what position it is and what value to use?
>>>Here what I am doing ...
>>>
>>>lcFileName = "C:\MyFile.txt"
>>>loExcel = CreateObject("Excel.Application")
>>>loExcel.WorkBooks.Open(lcFileName, 2, 1, 1, 2, .F., .F., .F., .T.)
>>>loExcel.visible = .T.
>>>
>>>
>>>I have tried variations of parameters and values but can't get it right.
>>>Any help would be greatly appreciated.
>>>
>>>Thanks,
>>>-Isaac
>>
>>Isaac,
>>Either use OpenText method where you can specify TextQualifier or as an easier way use CSV format. Excel opens it directly seeing extension.
>>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