title: Excel sheet Pre Populated Formulas values not refreshed
body: <p>I have a requirement where excel file ( i will treat this is an a template) which has a pre populated formulas ( for close to 10k rows), when i populate the dependent column values the formulas calculations are not updated or refreshed. please help me with the same.</p>
  
  <p>The formulas will be populated for 10k rows but while populating the data i may be populating the data just for 100 rows but user can add many more records later so we populate the formulas for 10k rows.</p>
  
  <p>Code below:</p>
  
  <pre><code>using DocumentFormat.OpenXml;
  using DocumentFormat.OpenXml.Packaging;
  using DocumentFormat.OpenXml.Spreadsheet;
  using Microsoft.IT.Sales.RelationshipManagement.Segmentation.DataContracts;
  using Newtonsoft.Json.Linq;
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace ConsoleApp1
  {
      class Program
      {           
          static void Main(string[] args)
          {           
              PopulateExcel("E:\\Formula.xlsx");            
              Console.WriteLine("Hello World!");
          }
  
          private static void PopulateExcel(string Path)
          {   
              WorkbookPart WP;
              //WorksheetPart WSP;
              String rId;
              Worksheet WS;
              SheetData StD;
              Row R1;
              Row R2;
              Row R3;
              Cell C1;
              Cell C2;
              Cell C3;
              CellFormula CF;
              CalculationChainPart CP;
              CalculationChain CC;
              CalculationCell CCell;
              Workbook Workbook;
              Sheet ss;
              Sheet Sheet;
  
              using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(Path, true))
              {
                  // Get the SharedStringTablePart. If it does not exist, create a new one.
                  WP = spreadSheet.WorkbookPart;
                  var wsp = spreadSheet.WorkbookPart.WorksheetParts.FirstOrDefault(); //.ElementAt(sheetnumber);
                  SheetData sheetData = wsp.Worksheet.Descendants&lt;SheetData&gt;().LastOrDefault();
  
                  R1 = GetRow(sheetData, 2);
                  C1 = new Cell();
                  SetCell(C1, "A1", 1);
                  sheetData.Append(R1);
  
                  R1.Append(C1);
  
                  C2 = new Cell();
                  SetCell(C2, "B1", 2);
  
                  R1.Append(C2);    
  
                  spreadSheet.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation = true;
                  spreadSheet.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;
                  wsp.Worksheet.Save();
  
                  // Close the document.
                  spreadSheet.Close();
              }   
          }
  
          private static Row GetRow(SheetData wsData, UInt32 rowIndex)
          {
              var row = wsData.Elements&lt;Row&gt;().
              Where(r =&gt; r.RowIndex.Value == rowIndex).FirstOrDefault();
              if (row == null)
              {
                  row = new Row();
                  row.RowIndex = rowIndex;
                  wsData.Append(row);
              }
              return row;
          }
          private static void SetCell(Cell cell, string Reference, int Value)
          {
              cell.CellReference = Reference;
              cell.DataType = CellValues.Number;
              cell.CellValue = new CellValue();
              cell.CellValue.Text = Value.ToString();
  
          }    
      }
  }
  </code></pre>
  
  <p>Please help me with the code.</p>