From 04431ed093e38d8dc874ec086c919578bb03f747 Mon Sep 17 00:00:00 2001 From: VinothSF5015 Date: Sun, 26 Apr 2026 17:14:20 +0530 Subject: [PATCH] 1017887 - Sample Added --- .../Formula Recalculation.slnx | 3 ++ .../Formula Recalculation.csproj | 19 +++++++++++ .../Formula Recalculation/Output/.gitkeep | 0 .../Formula Recalculation/Program.cs | 34 +++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation.slnx create mode 100644 FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Formula Recalculation.csproj create mode 100644 FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Output/.gitkeep create mode 100644 FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Program.cs diff --git a/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation.slnx b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation.slnx new file mode 100644 index 00000000..63a59110 --- /dev/null +++ b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation.slnx @@ -0,0 +1,3 @@ + + + diff --git a/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Formula Recalculation.csproj b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Formula Recalculation.csproj new file mode 100644 index 00000000..5a1cc0ef --- /dev/null +++ b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Formula Recalculation.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + Formula_Recalculation + enable + enable + + + + + + + + Always + + + diff --git a/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Output/.gitkeep b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Program.cs b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Program.cs new file mode 100644 index 00000000..b11b9b58 --- /dev/null +++ b/FAQ/Formula Recalculation/.NET/Formula Recalculation/Formula Recalculation/Program.cs @@ -0,0 +1,34 @@ +using Syncfusion.XlsIO; + +class Program +{ + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + // Set up sample data + worksheet["A1"].Value2 = 10; + worksheet["A2"].Value2 = 20; + worksheet["A3"].Value2 = 30; + + // Create formulas + worksheet["B1"].Formula = "=A1*2"; + worksheet["B2"].Formula = "=A2*2"; + worksheet["B3"].Formula = "=A3*2"; + + worksheet.EnableSheetCalculations(); + // Move range B1:B3 to C1:C3 + worksheet["B1:B3"].MoveTo(worksheet["C1:C3"]); + + // Clear the formula info table to ensure dependent formulas recalculate + worksheet.CalcEngine.FormulaInfoTable.Clear(); + + // Now the formulas will recalculate correctly when their values are accessed + workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx")); + } + } +}