// Hook: AfterCalculation // Halt the job if the Summary total cell is blank or zero after calculation. // // Empty totals usually indicate a datasource connection problem. Catching the // problem here prevents an empty report from reaching an executive inbox. var sheet = Workbook.Worksheets["Summary"]; if (sheet == null) { AddWarning("Sheet 'Summary' not found - skipping total validation."); return; } var totalCell = sheet.Cells["B2"]; if (totalCell.Type == CellValueType.IsNull || (totalCell.Type == CellValueType.IsNumeric && totalCell.DoubleValue == 0)) { AddError("Summary!B2 is zero or blank after calculation. This usually indicates a datasource connection problem. Job halted."); } Logger.LogInformation($"Total validation passed - B2 = {totalCell.Value}");