// Hook: BeforeCalculation // Push job parameters into a "Settings" sheet before formulas run. // // Any formulas that reference Settings!B1..B3 will pick up the values supplied // at runtime instead of whatever was last saved in the file. Add additional // Seed(...) calls to wire up more parameters. var settings = Workbook?.Worksheets["Settings"]; if (settings == null) { AddWarning($"No 'Settings' sheet found in '{OutputName}'; skipping parameter seeding."); return; } void Seed(string cell, string paramName) { if (Parameters.TryGetValue(paramName, out var value) && !string.IsNullOrWhiteSpace(value)) { settings.Cells[cell].PutValue(value); Logger.LogInformation($"Seeded Settings!{cell} = '{value}' from parameter '{paramName}'."); } } Seed("B1", "Region"); Seed("B2", "Period"); Seed("B3", "Currency");