Copying Data from a .txt file in order to populate an excel file

Hello

I have a txt. file
with data such as


1 2 24 42 24 42 42 52
3 3 53 23 53 23 53 23
...


I know how many columns there are but I don't know the amount of rows (3000+)
On the text files most of the columns are separated by " " but from time to time I get more than 1 space ie. " " but this is always constant all through out the other files,

I want to open that text file, save the data into an array and then populate an excel file which already has a format and data on it (such as headers..etc etc)

so my excel file would look like this...
X Y AA XS FD DS FE FE
1 2 24 42 24 42 42 52
3 3 53 23 53 23 53 23
...


I would already have the headers pre=written on my excel file....

Whats the best way to do this?

I am having a lot of trouble outputting anything into an excel file overall...


Saving the array wouldn't be an issue...I imagine I would count how many rows there are and then simply adjust the array to carry that many rows (3D array)

This doesn't have to be done in C++ so if anyone knows a more efficient/faster way, please so share it.
The easiest way to write a file that Excel can read is to write a comma delimited file with extension .csv. Excel and read and write these files, but it'll be raw numbers and/or strings.

Don't even consider modifying native Excel files yourself.

If you want to modify an Excel file and preserve formatting, you need to use Excel's automation interface. This uses COM to run Excel as a COM server, your app talks to it thru it's COM interface.

An example is here: http://support.microsoft.com/kb/308407
I found this example, but I can't comment on how helpful it might be: http://www.codeproject.com/KB/office/ExcelwithMC.aspx
Topic archived. No new replies allowed.