// Hook: BeforeCalculation // Force deterministic formula calculation regardless of the source workbook's // saved settings. // // Some Excel templates ship with calculation mode set to Manual, which makes // downstream recalculation behave unexpectedly. Normalising the formula // settings here keeps results consistent across environments. if (Workbook == null) { AddWarning($"No workbook available for '{OutputName}'; skipping calc-mode normalization."); return; } var formula = Workbook.Settings.FormulaSettings; formula.CalculationMode = CalcModeType.Automatic; formula.EnableIterativeCalculation = true; formula.MaxIteration = 100; formula.MaxChange = 0.001; formula.CalculateOnOpen = true; Logger.LogInformation($"Calc mode normalized to Automatic for '{OutputName}'.");