title: open xml sdk excel formula recalculate cache issue
body: <p>I have looked at all the previous answers to the similar questions in SO but those answers do not work. I pass in the value in excel and want the formula cell to recalculate but its still showing up the old value. </p>
  
  <p>I have used the 2 techniques 1) remove the calculated value from the cell 2)Open and close the file programmatically. Both of them don't work for me. Here is my code. Please help.</p>
  
  <pre><code>            string filename = Server.MapPath("/") + "ExcelData.xlsx";
  
  
  
              // getting 2 numbers in excel sheet, saving, and closing it.
  
              using (SpreadsheetDocument document = SpreadsheetDocument.Open(filename, true))
              {
                  Sheet sheet = document.WorkbookPart.Workbook.Descendants&lt;Sheet&gt;().SingleOrDefault(s =&gt; s.Name == "myRange1");
                  if (sheet == null)
                  {
                      throw new ArgumentException(
                          String.Format("No sheet named {0} found in spreadsheet {1}", "myRange1", filename), "sheetName");
                  }
                  WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id);
  
                  int rowIndex = int.Parse("C3".Substring(1));
  
                  Row row = worksheetPart.Worksheet.GetFirstChild&lt;SheetData&gt;().
                          Elements&lt;Row&gt;().FirstOrDefault(r =&gt; r.RowIndex == rowIndex);
  
                  Cell cell3 = row.Elements&lt;Cell&gt;().FirstOrDefault(c =&gt; "C3".Equals(c.CellReference.Value));
                  if (cell3 != null) 
                  {
                      cell3.CellValue = new CellValue("13");
                      cell3.DataType = new DocumentFormat.OpenXml.EnumValue&lt;CellValues&gt;(CellValues.Number); 
                  }
  
                  document.WorkbookPart.WorksheetParts
     .SelectMany(part =&gt; part.Worksheet.Elements&lt;SheetData&gt;())
     .SelectMany(data =&gt; data.Elements&lt;Row&gt;())
     .SelectMany(row1 =&gt; row1.Elements&lt;Cell&gt;())
     .Where(cell =&gt; cell.CellFormula != null &amp;&amp; cell.CellValue != null)
     .ToList()
     .ForEach(cell =&gt; cell.CellValue.Remove());
  
                  worksheetPart.Worksheet.Save();
  
              }
  
  
  
              // getting the result out of excel.
              using (SpreadsheetDocument document = SpreadsheetDocument.Open(filename, false))
              {
                  document.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation = true;
                  document.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;
  
                  Sheet sheet = document.WorkbookPart.Workbook.Descendants&lt;Sheet&gt;().SingleOrDefault(s =&gt; s.Name == "myRange1");
                  if (sheet == null)
                  {
                      throw new ArgumentException(
                          String.Format("No sheet named {0} found in spreadsheet {1}", "myRange1", filename), "sheetName");
                  }
  
  
  
                  WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id);
  
                  int rowIndex = int.Parse("C4".Substring(1));
  
                  Row row = worksheetPart.Worksheet.GetFirstChild&lt;SheetData&gt;().
                          Elements&lt;Row&gt;().FirstOrDefault(r =&gt; r.RowIndex == rowIndex);
  
                  Cell cell = row.Elements&lt;Cell&gt;().FirstOrDefault(c =&gt; "C4".Equals(c.CellReference.Value));
  
                  calculatedvalue = Convert.ToDouble(cell.CellValue.InnerText);
              }
  </code></pre>