How to open Excel sheet with full access in c#?

how can I access the formula in an excel sheet with c#?

  • I am parsing thorugh a 2000+ record excel file, and need ot be able to grab the formula itself from the cells and not just the value. For example, one cell 'Contributions' may be a single number like 1500 or it can be a few numbers 1500+500-200 but I dont want the total, I want the actual formula so I can get the different numbers. I was just parsing with an oledbconnection and that only seems to get me the total. How would I go about getting the formula? Is it possible (I can get it in either XLS or XLSX)? Thank you.

  • Answer:

    Using OLE Automation, you can access the formula in a cell as follows: formula = worksheet.Cells(1, 1).Formula EDIT: To use OLE Automation in your C# project, see the following http://support.microsoft.com/kb/302084:

Stuck In Baghdad at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

The xslx is an xml file so it should be easy enough to read. Alternatively you can use third-part components like the one from http://www.infragistics.com/dotnet/netadvantage/winforms/infragisticsexcel.aspx that allows you to read xsl-files programmatically and also to access the formulas.

Rune Grimstad

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.