public static void bloom(string col, int li, string formule) { //Copie du template et ouverture du fichier System.IO.File.Copy("TemplateBloom.xlsx", "BloomGenerated.xlsx", true); SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open("BloomGenerated.xlsx", true); //myWorkbook.WorkbookPart.Workbook.NamespaceDeclarations //myWorkbook.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation = true; //myWorkbook.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true; //Access the main Workbook part, which contains all references. WorkbookPart workbookPart = myWorkbook.WorkbookPart; WorksheetPart worksheetPart = workbookPart.WorksheetParts.ElementAt <WorksheetPart>(2); SheetData sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>(); sheetData.RemoveNamespaceDeclaration("x"); //CalculationChainPart calculationChainPart1 = workbookPart.AddNewPart<CalculationChainPart>("rId7"); //GenerateCalculationChainPart1Content(calculationChainPart1,"C2",1); CalculationChain CC = workbookPart.GetPartsOfType <CalculationChainPart>().First().CalculationChain; CalculationCell calculationCell = new CalculationCell() { CellReference = col + li }; CC.Append(calculationCell); //GenerateCalculationCell(CC, "C3", 1); Row r = (Row)sheetData.ChildElements.GetItem(2); Cell cell = GenerateCell(col + li, formule); //Cell cell = (Cell) r.ChildElements.GetItem(2); //cell.DataType = CellValues.Error; //cell.CellValue.Text="#NAME?"; //cell.CellFormula.Text = formule; r.RemoveNamespaceDeclaration("x"); cell.RemoveNamespaceDeclaration("x"); r.AppendChild(cell); CalculationChainPart ccp = workbookPart.CalculationChainPart; workbookPart.DeletePart(ccp); myWorkbook.WorkbookPart.Workbook.Save(); myWorkbook.Close(); }