?
Solved

import text file into excel

Posted on 2003-02-25
5
Medium Priority
?
280 Views
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.
0
Comment
Question by:anees31
[X]
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
5 Comments
 
LVL 5

Accepted Solution

by:
Nass89 earned 200 total points
ID: 8031454
Search the MSDN for word "Q186122", or visit
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186122
you will find very interesting things.
Good luck
0
 
LVL 1

Assisted Solution

by:Ess
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;
app.CreateDispatch("Excel.Application");
//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);
app.DetachDispatch();

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!!
0

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