I am using the following piece of code as part of a larger project - the program basically reads a spreadsheet based on the sheet selected from a drop down box - it then assigns the results to a datatable - I have a for loop that runs the following function to get the Cell content and add it to the datatable
public string GetValue(Cell cell, SharedStringTablePart stringTablePart)
{
if (cell.ChildElements.Count == 0) return null;
//get cell value
string value = cell.ElementAt(0).InnerText;//CellValue.InnerText;
//Look up real value from shared string table
if ((cell.DataType != null) && (cell.DataType == CellValues.SharedString))
value = stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText;
return value;
}
In the spreadsheet I am using however this returns a formula rather than the result. The Spreadsheet formula is =Sheet1!A12, essentially, whatever the user has entered into Sheet1 A12 should be displayed in the cell. Now the spreadsheet has the information already filled in but the program doesn't pull that result only the formula.
An example of this would be: Sheet 1 A12 contains the word "Dog" that means that in Sheet2 the Cell A4 has the formula =Sheet1A12 and should display "Dog" (which it does in excel but not in the program).
Is OpenXML capable of displaying the result considering it already exists?