Link to home
Start Free TrialLog in
Avatar of ak5745
ak5745

asked on

Appending Array to Excel Using C#

Experts,

I'm trying to append an array of strings to an already existing Excel 2007 file - there's already data in the file, and I'd like to add my new data to the first empty row.

As File.AppendAllText doesn't exist in this context, is there something that will give me the same usability? Any tips? Thanks!
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

While I am sure there are other methods I would create a csv file with C# and then use a macro in the excel document to import the data from the csv. While this is a two step process it is easy to implement

Michael
Avatar of ak5745
ak5745

ASKER

Thanks for the reply. I'd like to have the capability of opening Excel and having all my data there already without having any additional steps.

If this is not possible, then I'll probably lean towards the csv route.

Any other ideas?
The only thing I can think of is

Save as csv
Create an excel document with a macro that opens the required file and the csv and then appends the data the existing file
Set the macro to run on file open
Call this document from your application

Problem is that this method is messy and there must be a better way to solve the issue

Michael
Avatar of ak5745

ASKER

You're right, it is messy. I know what I'm describing here is essentially a log in excel. Given I can do this, I'd like entries to be added with most recent being placed on top (below a header), where I'll eventually use excel to do analysis of this data.
Avatar of ak5745

ASKER

Does anyone already do this in any apps they manage? It doesn't strike me as cosmic, but maybe it is. Anyone have any tips/code snippets that might help me out?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of ak5745
ak5745

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ak5745

ASKER

I found a solution that works for me. Hope it's useful.