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
Other answers
A quick google found the following: http://codingsense.wordpress.com/2009/03/01/get-all-formula-from-excel-cell/
Mitch Wheat
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:
- How can i access the number of questions asked on stackoverflow?Best solution by Meta Stack Overflow
- How can I access my localhost from my Android device?Best solution by Stack Overflow
- How can I access file in localhost?Best solution by Stack Overflow
- How can I access my Internet Explorer history?Best solution by wikihow.com
- How can I access my group in Yahoo?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.