import text file into excel

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-20
I want to convert the text file .txt into an Excel file using VC++. I don't want to do by manual method (like
saving the file as .csv and using text import wizard)
The code to convert text file has to be provided.
Question by:anees31
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Nass89 earned 200 total points
ID: 8031454
Search the MSDN for word "Q186122", or visit
you will find very interesting things.
Good luck

Assisted Solution

Ess earned 200 total points
ID: 8040414
Use automation to do it.  First go to the class wizard and then select add class, then select from type library.  Choose the excel type library from the office directory.  For Office 2000 it is excel9.olb.  Add all the classes unless you know that you will not need some of them.  After creating the classes create an instance of the application class.  I don't know the exact name of it but will be similar to _Application;

Create the class instance as follows:
_Application app;
//Create a workbook collection
Workbooks wbooks(app.GetWorkbooks());
//Create a individual workbook that will contain the file
_Workbook wbook;
//Create the workbook by import text file
wbook = wbooks.OpenText(See MS Excel help for parameters);
//Save the workbook
wbook.SaveAs(See MS EXcel help for parameters);

I don't know the exact class names but they will be similar to above.  Also if you have to use constants in the functions you cannot use the Excel defined constants.  Open OleView for the Excel automation object and see what the constant's numerical values are.  These are the values you use in the functions created by class wizard.

Good Luck!!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question