// Hook: BeforeCalculation // Stamp a hidden "_Meta" sheet with generation context. // // Readers who open the file later can look at this sheet to see when the // workbook was refreshed and which department it was generated for. The // metadata is in place before calculation, so any formulas can reference it. var meta = Workbook.Worksheets["_Meta"]; if (meta == null) { AddWarning("Metadata sheet '_Meta' not found - skipping stamp."); return; } meta.Cells["A1"].PutValue("Generated by ReportWORQ"); meta.Cells["B1"].PutValue($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); if (Parameters.TryGetValue("Department", out var dept)) meta.Cells["C1"].PutValue(dept); meta.AutoFitColumns(); Logger.LogInformation($"Stamped generation metadata for '{OutputName}'.");