Download Reportworq
⬇ Guide PDF

Example scripts#

Reportworq ships a library of .csx examples, one set per hook plus two that span every hook. They are the fastest way to see the script API used in context, and most are close enough to production use to adapt directly.

Every example is compile-checked against the real script API on each build, so the library cannot drift as the API changes.

Download#

Download all examples (.zip)

The zip preserves the folder-per-hook layout below. Individual scripts are linked from each table.

Before you adapt one#

Before Processing#

Runs before distributor pre-flight and before any report is calculated. There is no workbook yet, so these are gate-keeping and preparation scripts.

Script What it does
Block On Weekends Block the job from running on Saturday or Sunday.
Copy ETL Export To Provider Copy a fresh data extract from an ETL share into the report provider folder.
Validate Required File Exists Halt the job if a required source file is missing.

Before Calculation#

Runs once per report, before its data source is calculated. The workbook exists but is not yet populated, which is the moment to validate inputs and seed cells.

Script What it does
Seed Settings Cells Push job parameters into a "Settings" sheet before formulas run.
Set Calc Mode Force deterministic formula calculation regardless of the source workbook's saved settings.
Stamp Metadata Sheet Stamp a hidden "_Meta" sheet with generation context.
Validate Named Range Exists Halt the job if a required named range is missing.
Validate Required Parameters Halt the job if any required parameters are missing or blank.

After Calculation#

Runs once per report, after its data source is calculated. The data is in the workbook, so this is where validation, formatting and redaction belong.

Script What it does
Apply Currency Format Apply a currency number-format to columns whose header mentions Amount, Total, or Revenue.
Redact PII Columns Mask values in any column whose header looks like personally identifiable information (PII).
Sort Details Sheet By Column Sort the "Details" sheet rows by column C, descending.
Stamp Watermark On All Sheets Stamp every visible worksheet with a small watermark in cell A1.
Validate KPI Threshold Halt the job if a KPI value is missing, negative, or absurdly large.
Validate Totals Not Zero Halt the job if the Summary total cell is blank or zero after calculation.

After Packet Generation#

Runs once, on the merged workbook, before format conversion. Changes here reach every output format derived from it, so this is the place to harden what gets distributed.

Script What it does
Hide Staging Sheets Hide any worksheet whose name starts with an underscore.
Protect Sheets With Password Apply sheet-level protection across every visible worksheet.
Remove Empty Sheets Remove worksheets that have no data after the packet was assembled.
Remove Formulas From Distribution Sheet Replace every formula on the "Distribution" sheet with its calculated value.
Set Workbook Properties Stamp the workbook's built-in document properties with job metadata.

After PowerPoint#

Runs after the PowerPoint file is generated. The presentation is available; the workbook is not.

Script What it does
Apply Footer And Slide Numbers Brand every slide with a consistent footer and visible slide numbers.
Remove Draft Slides Remove draft slides and any slide marked Hidden in the source deck.
Replace Tokens On Slides Replace simple tokens in slide text without losing the existing formatting.
Stamp Slide Footer Stamp every slide with a small footer text frame showing report name and generation date.
Validate Minimum Slide Count Halt the job if the presentation has fewer than the expected number of slides.

After Send#

Runs after every distributor has been called, whether distribution succeeded or failed. The job result is available, and the files have already gone out.

Script What it does
Append Audit CSV Append a one-line audit entry to a shared summary CSV.
Teams Webhook On Failure Send a Microsoft Teams webhook notification when a job fails.
Trigger Downstream API POST to a downstream HTTP API once distribution completes successfully.

Multi-hook examples#

These attach to several hooks at once and branch on HookName to tell which one they are in.

Script What it does
Audit Every Hook Event Append a one-line CSV entry every time a hook fires during a job.
Random Failure Demo A demo script that occasionally surfaces a comical error.

Feedback on this page

Comments, questions, requests, or something missing or unclear? Email us - the page you are on is filled in for you.

Email feedback on this page

Or write to support@reportworq.com directly.