none
Using Excel functions in C# code in program completely independent of Excel RRS feed

  • Question

  • Hi Guys,

    I would like to use Excel spreadsheet in C# code. In a windows form environment. Im looking particularly for the function coupdayBs. Can someone help please. I tried to dig into lib Microsoft.Office.Interop.Excel but there no class to make calculations.

    Regards,


    Sherman Body love

    Monday, October 21, 2013 9:42 PM

Answers

  • As others stated, you need Excel installed.

    [But using Excel on server is bad as it is a front end product that very happily communicates with user through UI.] <- sentence valid only if you are running a server/service/non-UI code.

    Instead you should go with a 3rd party library (i.e. DevExpress) that provides managed library to manipulate Excel files (even displays those in a way similar to Excel). No outside references required nor Excel itself.


    Miha Markic [MVP C#] http://blog.rthand.com


    Wednesday, October 23, 2013 9:27 AM

All replies

  • Microsoft.Office.Interop.Excel uses Excel APIs and cannot be used without excel installed.

    Although you can use third-party applications to open excel files, they are not as feature-rich compared to excel, and are not that friendly to programmers. 



    Visual C++ MVP

    Monday, October 21, 2013 10:37 PM
  • I have Excel installed of course. Otherwise I wouldnt be able to see dll Microsoft.Office.Interop.Excel.dll.

    Are you telling me that You cannot use Excel functions outside Excel itself? So I cannot use function coupdayBs in a common C# program?

    Please confirm

    Thanks,


    Sherman Body love

    Tuesday, October 22, 2013 1:46 PM
  • You got to have the software that implemented the function. Of course you can write the function by yourself if you write an excel format parser and provide a UI editor for the file, similar to what open office does, but that would probably cost you a few years. 


    Visual C++ MVP

    Tuesday, October 22, 2013 3:01 PM
  • As you can use the Functions in VBA Macros, you can use all of the functions through interop.
    Tuesday, October 22, 2013 3:17 PM
  • As others stated, you need Excel installed.

    [But using Excel on server is bad as it is a front end product that very happily communicates with user through UI.] <- sentence valid only if you are running a server/service/non-UI code.

    Instead you should go with a 3rd party library (i.e. DevExpress) that provides managed library to manipulate Excel files (even displays those in a way similar to Excel). No outside references required nor Excel itself.


    Miha Markic [MVP C#] http://blog.rthand.com


    Wednesday, October 23, 2013 9:27 AM