2

I've been using Closed XML to generate my Excel reports automatically. So far so good, but however I need to save certain formula-generated values back into the database.

The formula would be something like this: =SUM(Day1, Day2, Day3), so simply an Excel formula parser would not fit my bill--I need something that can interact with it!

I don't mind having to save the spreadsheet and then re-opening it. So long as it's fast and efficient, I'm up for anything. Thanks a bunch. :)

2 Answers 2

2

You can use

Range("D1").value 

for getting the value of the formula

Sign up to request clarification or add additional context in comments.

3 Comments

What if, I can only get the cell from a row-col (int, int) reference?
@matt Have a look here for a way to convert your integer column number to an Excel column name (remember to account for your possibly-zero based number).
IXLWorksheet's Range().Value does not have a get accessor... says the code
1

You can use something like:

if(ws.Cell(i, j).HasFormula) 
       VAL = ws.Cell(i, j).ValueCached
else
       VAL = ws.Cell(i, j).Value.ToString()

1 Comment

Code only answers are discouraged on StackOverflow. Please try to elaborate a little as to why this is a correct answer..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.