Comma-Delimitted Text File to Excel

I would like someone to explain me with detail if there's any component or rutine to convert a comma-delimitted text file into a excel sheet.

Thanks very much.
LVL 1
quiqueAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GreymanConnect With a Mentor Commented:
1)Drop an OLEContainer on your form.

2) In the relevant bit of code:

OLEContainer1.CreateObject('Word.Application',True);
OLEContainer1.OLEObject.Workbooks.Open('MyFile.csv',null,2,null..[lots of nulls here - check the programmer's help in Excel for the exact interface].);
OLEContainer1.OLEObject.Workbooks[1].SaveAs(See the Excel help for exact usage);

Have a look under TOLEContainer in the Delphi help, and in the Excel reference under the Workbooks object for more.
0
 
JoeBoothCommented:
Some questions to consider:

Is Excel on the machine that will be doing the conversion?  If so, you can use the COM objects that come with Delphi 5 to create Excel spreadsheets.

If Excel is not installed, or if you'd prefer not to use COM, consider the following component (it sells for $30).

http://www.axolot.com/components/xlsreadwrite.htm

This component allows you to write cells directly to Excel files and works great.  I am a very happy customer of the component.  

If you purchase the component, you can use the ASCII driver to read the text file and use the components methods to write the cells..
0
 
quiqueAuthor Commented:
I have Delphi 4 and I don't want to purchase any product.

There's must be an easier way to do it!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
simonetCommented:
Excel already reads CSV files.

Alex
0
 
men xinCEOCommented:
following
0
 
JoeBoothCommented:
Will Excel be installed on the machine that is running the conversion?
0
 
quiqueAuthor Commented:
Yes, it will be installed.
0
 
JoeBoothCommented:
If Excel will be installed, you can use the Excel OLE automation object for the conversion.  Unfortunately, I do not have any sample code showing how to do it.  If someone else does provide sample code, I'll see if I can dig it up from my home office.
0
 
quiqueAuthor Commented:
But remember what I have is a text file delimitted by commas, not a stringgrid or even an array or something like that. I only want to conver that text file into an excel sheet without "disturbing" the user
0
 
Phoenix_sCommented:
excel already imports CSV files with no problems... no need to write a conversion routine
0
 
quiqueAuthor Commented:
Phoenix, I don't want the user to work at all!
0
 
quiqueAuthor Commented:
Greyman, I'll try it and tell you.

Quique.
0
All Courses

From novice to tech pro — start learning today.