Hello everybody,
is it possible to write a function for excel with c-sharp?
I`ve found an interesting atricle which describes such a scenario (the url) but it`s about visual studio 2005. I tried it with visual studio 2010 but it doesn`t work for me.
Can anybody help me please!
Wish you a nice day
Loading

Suthish NairRank #92 · 22.8K reputationPosted Oct 19, 2010, 12:47 PM EDT
Sorry for posting so many links, here an msdn working sample, try it and let us know.
more
Posted Oct 17, 2010, 5:02 AM EDT
http://www.dotnetspider.com/forum/534-Read-Write-excel-file-from-C.aspx
http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/4b8c7a76-db36-4f53-ab92-0b27faa65521
Sam HobbsRank #107 · 20.5K reputationPosted Oct 17, 2010, 12:09 PM EDT
Chr leog17 reputationPosted Oct 17, 2010, 10:13 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Oct 18, 2010, 12:50 AM EDT
Chr leog17 reputationPosted Oct 18, 2010, 3:13 AM EDT
I will try it as soon as i can
Chr leog17 reputationPosted Oct 18, 2010, 4:28 AM EDT
Step 1 say, i should create a class library called ExcelAddin. Ok, the output of this is a dll-file (not an executable). Afterwards, I am following the instructions, copy the c# code nto the class file.
Next point is to run the code. The instructions say, that i should build the ExcelAddin and press F5 (compile). When I press F5, visual studio say that the project can`t start beacause it`s a library, not an executable.
What is the problem here? In the article it says, Build the ExcelAddin and press F5?
Any clues?
Sorry, my os is Windows 7 Professional with .NET Framework 4.0. I`m using Visual Studio 2010
Krishnendu Banerjee8 reputationPosted Oct 18, 2010, 8:53 AM EDT
You can use this dll file as adding a reference in any executable project like a windows application and after adding the dll you can use its methods and properties in your executable.
Also you can check articles in the internet on how to use a windows .dll file in C# application.
Sam HobbsRank #107 · 20.5K reputationPosted Oct 18, 2010, 10:56 AM EDT
The problem is likely that you have chosen the wrong sample. You have chosen a sample that creates an Add-In and it sure sounds as if you don't need an Add-In. Have you looked at the articles in this web site?
Chr leog17 reputationPosted Oct 18, 2010, 9:56 PM EDT
that`s correct. I am a windows programming beginner but i programmed a long time with java and so, c# is very easy for me. And that is the cause i want to programme an excel addin in this language (c#) and not vb because i don`t know anything about vb. Still, I`m a Linux-User and not so experienced with MS, I want to learn it.
The article say i should use a Visual C# Class library. And that was the thing i did. I didn`t use an excelAddIn (there are still project-samples for excel but i used the visual c# class library).
And of course, a class libray is either static or dynamic (dll) (references on my c++ knowledge). And i also knew, that i can`t run a class library such as an excecutable. But when i tick the checkbox " Register for COM Interop", i don`t know what`s happening with the library. Can i execute it or not (apparently not :) ...
I would be pleasant if you give me an answer (I know, beginners are exhausting sometimes and they should learn basics first, but this is a thing i want to deal with)
Sam HobbsRank #107 · 20.5K reputationPosted Oct 18, 2010, 10:33 PM EDT
I can't give you an answer because I don't know the question.
By definition of what an add-in is, an add-in cannot be executed by itself. So the question remains: are you sure you need an add-in?
One more thing: a static library is not a DLL and an add-in must be a DLL.
Chr leog17 reputationPosted Oct 18, 2010, 11:11 PM EDT
For example i want to create my own calculate()-function with c# and on my excel-sheet, i want to write in a cell (eg A1) calculate() ... and it should return the value ...
And the article says ( url), that i should create a class library.
@static library is not a DLL and an add-in must be a DLL.
Yes, I know ;) (it was only to show that i already have a bit knowledge, and i didn`t want to say that a static library is a dll)
Chr leog17 reputationPosted Oct 20, 2010, 11:01 AM EDT
@Suthish Nair
Fantastic link. This blog-post worked for me. I`ve looked for that description so long but i didn`t find it.
Thanks very much Mr Suthis Nair, and of course all others too
which you a nice week.