This guide walks you through configuring the Reports module to generate PDF/text reports and exchange data with external systems. You'll create report forms with real-time data, configure web data exchanges, and schedule automatic generation.
Prerequisites:
Property | Description | Example |
---|---|---|
Name | Form identifier | DailyProductionReport |
SaveFormat | Output type | PDF, Text, HTML |
SaveFileName | File path | C:\Reports\Daily_{{Tag.Date}}.pdf |
SaveTrigger | When to generate | Tag.GenerateReport |
Append | Add to existing file | 0=Replace, 1=Append |
{Tag.TagName}
Method 1: Direct Typing
Current Temperature: {Tag.Temperature} °C
Production Count: {Tag.ProductionCounter}
Operator: {Tag.OperatorName}
Method 2: Tag Browser
Static Tables (Fixed rows):
Dynamic Tables (Database queries):
Header Row: Column names for report
Data Row: {Dataset.Query.ProductionData}
Example dynamic table setup:
Report Column | Database Column |
---|---|
Product Name | ProductName |
Quantity | {Tag.Quantity} |
Quality | QualityScore |
Property | Description | Example |
---|---|---|
Name | WebData identifier | ProductionAPI |
Encoding | Data format | JSON, XML, HTML |
DefaultURL | API endpoint | https://api.example.com/data |
Authorization | Auth type | Bearer Token, Basic Auth |
JSON Example:
json
{
"timestamp": "{Tag.CurrentTime}",
"production": {
"line": "{Tag.ProductionLine}",
"count": {Tag.ProductionCount},
"quality": {Tag.QualityScore}
}
}
GET Request:
csharp
// Retrieve data from API
string response = await @Report.WebData.ProductionAPI.GetRequestAsync();
@Tag.APIResponse = response;
POST Request:
csharp
// Send data to API
// Body configured in WebData Editor
await @Report.WebData.ProductionAPI.PostRequestAsync();
From Scripts:
csharp
// Save report to file
@Report.Form.DailyReport.Save();
// Generate with custom filename
@Report.Form.DailyReport.SaveAs("CustomReport.pdf");
Using SaveTrigger:
csharp
// In startup script
@Report.Form.DailyReport.SaveTrigger = @Tag.DailyTrigger;
// In scheduled script (runs daily at 6 AM)
@Tag.DailyTrigger = 1;
@Tag.DailyTrigger = 0;
For rich text reports:
csharp
// Switch language before generation
@Client.Localization = "Spanish";
@Report.Form.DailyReport.Save();
Use callback function for dynamic formatting:
csharp
public void OnReportCustomTableCell(string reportName,
string columnName, DataRow row, TableCell cell)
{
if(Convert.ToDouble(row["Value"]) > 100)
{
cell.Background = Brushes.Red;
}
}
csharp
// After report generation
@Script.Email.SendReport(
"recipient@example.com",
"Daily Report",
@Report.Form.DailyReport.SaveFileName
);
Report Not Generating
Missing Data in Report
{Tag.Name}
PDF Layout Issues
WebData Connection Failed
? Use meaningful names - Clear identification for forms and WebData ? Test tag values - Verify data before generation ? Handle errors - Check file write permissions ? Version control - Include timestamps in filenames ? Optimize queries - Run database queries before report generation ? Document templates - Maintain template library ? Schedule wisely - Generate during low-activity periods