// Hook: AfterCalculation // Stamp every visible worksheet with a small watermark in cell A1. // // The watermark shows the report output name and generation timestamp so // recipients always see provenance even if the workbook is saved and reopened // later. Hidden sheets are skipped. using System.Drawing; foreach (var ws in Workbook.Worksheets) { if (!ws.IsVisible) continue; ws.Cells["A1"].PutValue($"{OutputName} - Generated {DateTime.Now:yyyy-MM-dd HH:mm}"); var style = ws.Cells["A1"].GetStyle(); style.Font.IsBold = false; style.Font.IsItalic = true; style.Font.Color = Color.Gray; ws.Cells["A1"].SetStyle(style); } var visibleCount = Workbook.Worksheets.Count(w => w.IsVisible); Logger.LogInformation($"Watermark stamped on {visibleCount} visible sheet(s).");