Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# and MS Excel 1

Status
Not open for further replies.

nphani

Technical User
Feb 10, 2002
104
US
Hello Friends,

I have an excel file that contains 3 columns like this:

A B C
------------------
<num1> <num2> $A * $B

So, basically columns A and B contain some numbers. Column C contains the product of the numbers in A and B, per row.

I want to write a C# code that writes into columns A and B and reads the result from C.

I am not sure if we can do this and I think we should be able to. If yes, how should I start.

Thanks
 
Is the only purpose to get the results from cell C by feeding it A and B? What kind of formula will be used that you cannot achieve with C# code alone?

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
The problem is the formula being used in Excel is like a external system's formula and we are not given rights to know it. So the only way (actually a quick fix for now) is to read the value from the excel file.

I know it sounds a little stupid, but i guess thats how quick fixes are :)
 
Use Primary Interop Assemblies. Seems to be my favourite answer today!! PIAs allow you to create/edit/delete/ Excel sheets and cells like it was being done when they are opened by a user.

Regards
Satish
 
Satish, can you point us to information about using Primary Interop Assemblies for this? Or provide a short code example?

The Help that comes with VS has a somewhat convoluted path to get there and all I'm seeing is very high-level stuff, not enought nitty-gritty to find the assembly for accessing Excel and some code samples for using it.

Thanks!

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Thanks Satish,

The links were really helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top