Generating S7-1200 Reports in TIA Portal: Excel Export Methods

David Krause14 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Generating tabular reports from an S7-1200 CPU and a 7-inch HMI panel is one of the most common integration requests on packaging lines, batching skids, and OEM machines. Operators need a CSV that can be opened in Excel for batch traceability, maintenance staff need alarm logs forwarded to engineering, and quality teams need production counters exported as an attachment. TIA Portal exposes several official paths to accomplish this — SMTP email from the CPU via TMAIL_C, HMI-side data logging to USB media, native WinCC report jobs, and FTP transfers — and each method has a distinct firmware, panel-class, and runtime impact profile that must be evaluated before committing to one in a bill of materials.

This reference consolidates the four supported export paths documented in the Siemens support database, including entry 109091876 for WinCC Advanced and the WinCC Unified report-job documentation, wires them to the actual TIA Portal configuration screens, and shows the engineering trade-offs so you can pick the right one for a given machine class.

Prerequisites

Before configuring any of the four export paths, verify that the hardware and software stack is on compatible revisions. Mixing report options across firmware generations is the most common source of unsupported-feature runtime errors.

Component Minimum Requirement Recommended Notes
CPU firmware S7-1200 V4.2 for TMAIL_C V4.4 or later TMAIL_C ships in the "Communication -> SMTP" library from TIA V13 SP1 onward; TLS variant needs V4.4+
TIA Portal V13 SP1 V18 / V19 / V20 Report designer and report jobs require V14 SP1+ for Comfort Panels; Unified report jobs need V17+
HMI panel KTP700 Basic (data log only) TP700 Comfort / MTP700 Unified Native WinCC reports need Comfort or Unified class; Basic panels only log CSV to USB
Storage medium USB stick <= 32 GB, FAT32 Industrial SD + SIMATIC HMI memory card Comfort panels read/write NTFS only from firmware V16 onward via the ET 200SP USB interface
DNS / SMTP Local SMTP relay, port 25 Authenticated SMTP with STARTTLS, port 587 TLS 1.2 requires CPU firmware V4.4+ and TIA V15.1+ for the TMAIL_C_SEC variant
Network egress TCP 25 outbound to relay TCP 587 + DNS over PROFINET Outbound filtering must allow SMTP from the machine VLAN
A 1217C CPU (firmware V4.6 in current delivery) is only required if you intend to evaluate OPC UA Pub/Sub as a side-channel for report distribution. For the four paths documented here, any S7-1200 from firmware V4.2 upward is sufficient, including the 1212C, 1214C, 1215C, and 1217C variants.

Method Comparison — Email, USB Logging, WinCC Report, and FTP

Criterion TMAIL_C Email HMI Data Log to USB WinCC Report Job FTP Server (CPU-side)
Trigger source PLC program HMI scheduled / event HMI scheduler PLC program
Output format CSV, TXT, raw bytes CSV (RDB-compacted shadow) PDF, RTF, XLSX (Comfort), PDF (Unified) CSV / arbitrary
Destination Email recipient USB / SD / network share Printer, file system, email FTP server
External software needed SMTP server None (operator pulls USB) None FTP daemon (IIS, FileZilla, vsftpd)
Panel class required Any (panel not involved) KTP400 Basic or higher Comfort / Unified only Any (panel not involved)
CPU load profile Medium (TCP open/close per send) None on PLC None on PLC; medium on panel Medium (FTP client in PLC)
Typical latency to file Seconds (mail queue dependent) Immediate on event Scheduled minute / hour / daily Seconds
Documented in TIA Portal Help -> SMTP library WinCC Advanced manual, chapter "Logs" Siemens Support entry 109091876 Siemens FTP example project for S7-1200

Method 1 — Sending a CSV Report by Email with TMAIL_C

The SMTP block TMAIL_C and its secure variant TMAIL_C_SEC is the most direct path from an S7-1200 to a recipient inbox. The block transmits any byte buffer as an attachment, so the engineering task reduces to formatting the report buffer as a CSV string and triggering the block on a rising edge. TMAIL_C is documented in the TIA Portal online help under "Communication -> SMTP" and is included in every TIA installation starting at V13 SP1.

Hardware and Network Setup

  1. Connect the S7-1200 PROFINET port to a routable network that can reach the SMTP relay. If the relay is on the office LAN, configure the CPU's IP, subnet mask, and default router under Devices & Networks -> CPU PROFINET interface -> Ethernet addresses.
  2. Reserve a static DNS entry or hard-code the SMTP server IP. TMAIL_C resolves hostnames only on CPU firmware V4.3 or later; earlier firmware requires the IP literal.
  3. Open TCP port 587 (STARTTLS) or 25 (plain) outbound on any firewall between the machine and the relay. Many plant firewalls block 25 by default.
  4. For TMAIL_C_SEC, import a CA certificate under Devices & Networks -> CPU Properties -> Security -> Certificate manager. Self-signed certificates require the CA to be added to the trusted root store on the CPU.

Building the CSV Buffer in the PLC

A CSV row is plain ASCII terminated by CR LF (0x0D 0x0A). For a typical shift report, build one DB of type Array[0..N] of Byte and fill it with a series of CHR operations in SCL. A minimal example in Structured Text:


// Shift report CSV builder
"dbReport".len := 0;
FOR i := 0 TO 17 DO
  "dbReport".buf[i] := CHAR_TO_BYTE("hdrLine"[i]);
END_FOR;
// Append rows by copying formatted REAL/INT fields
// Insert 0x22 0x3B 0x22 between fields and 0x0D 0x0A at row end

Keep the total buffer under 32 KB for first-pass commissioning. The SMTP library accepts up to roughly 60 KB reliably; above that, chunk the shift into multiple files or compress the buffer before the call. Note that the LEN input on the instance DB must equal the exact number of payload bytes — passing the DB size will result in a partial or padded attachment.

Calling TMAIL_C — Input Map

Input Type Example Value Description
REQ BOOL Rising edge on shift end Triggers send; idempotent while BUSY=TRUE
ID CONN_OUC 1 Connection ID from the Connections tab of the instance DB
TO_S STRING[254] '[email protected]' Recipient list, semicolon separated
CC STRING[254] '[email protected]' Optional CC
SUBJECT STRING[254] 'Shift report 2024-05-12' Subject line, no CRLF
TEXT STRING[254] 'See attachment.' Plain-text body
ATTACHMENT VARIANT pointer "dbReport" Pointer to the CSV buffer DB
FILENAME STRING 'ShiftReport.csv' Filename shown in the mail client
USERNAME / PASSWORD STRING '[email protected]' SMTP AUTH credentials

Wire REQ to a one-shot rising edge from the shift-end logic and evaluate DONE, BUSY, and ERROR / STATUS for diagnostic output. Persist the last STATUS value to a HMI-visible tag for remote diagnostics.

For TLS-protected relays, replace TMAIL_C with TMAIL_C_SEC (introduced in TIA V15.1) and select the certificate slot in the instance DB. Plain SMTP on port 25 is increasingly blocked by upstream providers — prefer authenticated SMTP with STARTTLS on 587.

Method 2 — Logging to USB on a KTP / TP Panel

For machines where no IT infrastructure exists, the operator can pull a USB stick from the panel door. This path is independent of the PLC and survives PLC CPU restarts, which is critical for post-mortem analysis after a station power-down.

Configuring the Data Log in TIA Portal

  1. In the TIA project tree, expand HMI -> Logs -> Data logs and double-click Add new.
  2. Select storage path USB storage or Network (SMB share).
  3. Add columns referencing tags from the PLC connection, for example "DB_Prod".Counter_Good, "DB_Prod".Counter_Reject, "DB_Prod".OEE, and "DB_Prod".BatchID.
  4. Set the log mode to Circular or Segmented. For a shift-aligned export, choose Segmented by time with a 480-minute segment (one per 8-hour shift).
  5. Define a trigger — either a scheduled trigger (every 60 s) or an event trigger tied to a ReportReady PLC tag.
  6. Compile and download the HMI project. The log begins populating at runtime start.

The panel writes a binary RDB file plus a CSV shadow. Plugging the USB stick into a PC reveals both; the RDB can be re-imported into WinCC for offline trend analysis, while the CSV opens directly in Excel with the comma separator (change the separator under Region in the data log properties for European installs).

Operator Workflow on a KTP700

  1. Insert a FAT32-formatted USB stick into the panel's USB port. Confirm the panel beeps and shows "USB recognized" on the status bar.
  2. Navigate to the user-defined report screen and press the "Save log" button.
  3. Confirm the on-screen file path, typically /media/simatic/HMI_Data/Logs/Shift_001.csv.
  4. Remove the USB and transfer the file to the historian PC via the standard file-share process.
Comfort Panels support NTFS only from firmware V16 onward and require the ET 200SP USB interface module (6ES7676-1AA00-0AA0). Basic panels (KTP700 Basic) accept FAT32 only. Industrial-grade USB sticks such as the Siemens 6ES7648-0DC50-0AA0 are recommended for environments above 40 °C.

Method 3 — Native WinCC Report (Comfort and Unified)

Native WinCC reports generate a formatted document — PDF on Unified, XLSX/PDF/RTF on Comfort — using the report designer. This is the only path that produces a printable page layout instead of a raw CSV, and is therefore the right choice for batch records and audit documentation.

Adding a Report Template (WinCC Advanced V13 SP1 and later)

Procedure per Siemens Support entry 109091876 — Create a report:

  1. In the project navigation, right-click Reports and choose Add new report.
  2. Open the report in the editor; drag Tag table, Alarm view, or Text list objects onto the layout page.
  3. Open Report properties (right-click the report header) and select the Layout tab. Choose the page size (A4) and orientation (portrait or landscape).
  4. In the Output tab, choose the printer, file path, or email destination.
  5. Save and download the HMI project to the panel.

Creating a Report Job (WinCC Unified V17 and later)

Procedure per the WinCC Unified — Creating a report job documentation:

  1. Open the Unified HMI project. Under Reports -> Report tasks, add a new task.
  2. Assign the report template created in the report editor.
  3. Select the Trigger: Time, Event, or Variable change.
  4. Define the Output: file-system path on the Unified runtime (e.g. /home/industrial/reports/), printer, or email via the configured SMTP user.
  5. For automatic emailing, the Unified runtime reads the SMTP user from Settings -> Mail. Configure username, password, host, port, TLS, and sender before testing.
  6. Activate the report task and observe the status under Diagnostics -> Report queue.

Exporting a Report Manually

On the HMI runtime, an operator presses a configured button bound to the system function PrintReport (Comfort) or the ExportReport script function (Unified). The panel prompts for a destination; on Unified, the file is exported to the configured storage path and can be retrieved via the panel's WebDAV interface on port 443.

Method 4 — FTP Push from the S7-1200

When the destination is a plant historian rather than an inbox, push the CSV over FTP. The S7-1200 acts as an FTP client using the FTP_CMD block from the same communication library.

  1. Configure the FTP server (Windows IIS, FileZilla Server, or Linux vsftpd) with a write-only user for the S7-1200.
  2. Import the FTP_CMD instance DB and set ID, CONNECTION_TYPE := FTP, and the remote path.
  3. Use the same CSV buffer built for Method 1; the FTP_CMD upload command accepts a VARIANT pointer to a byte DB.
  4. Schedule the upload at shift end via a one-shot from the shift bit, and persist the result code to a HMI-visible diagnostic tag.

FTP passes credentials in cleartext. If the historian is outside the OT zone, terminate the session at a firewall and prefer SFTP from a Unified panel instead. Plain FTP should be limited to isolated engineering VLANs.

CSV Format and Excel Compatibility

Excel auto-detects field separators from the regional locale list. On a German Windows install, ; is the default separator; on US English, it is ,. To keep a single file usable in both environments, embed the separator declaration on the first line and add a leading UTF-8 BOM (0xEF 0xBB 0xBF) so Excel reads the file as UTF-8 unconditionally:


sep=;
"Timestamp";"Counter_Good";"Counter_Reject";"OEE"
"2024-05-12 06:00:00";1234;12;0.91
"2024-05-12 06:01:00";1244;12;0.91

This pattern is consumed natively by Excel 2016+ and LibreOffice Calc 7+ without an import wizard. For a Word-style report, generate an RTF template from a Comfort panel report job instead — RTF preserves paragraph and table formatting when opened in Word.

Verification Procedure

  1. Build check: compile the project (Ctrl+B) in TIA Portal. Watch for warnings about SMTP library version mismatches; clear all warnings before download.
  2. Download: connect to the target CPU and the HMI panel. After the CPU download, force the shift-end bit and observe the rising edge on TMAIL_C.REQ.
  3. Mail check: open the recipient mailbox; verify the subject, body, and that the attachment opens without a "file format may be incorrect" warning. Verify the byte count by re-saving and comparing file size in mail client and DB.
  4. USB check (Method 2): insert a USB stick, trigger a log entry, remove the stick, open the file in Excel; confirm columns and decimal separator.
  5. Report job check (Method 3): open the Unified diagnostics page, confirm the report task status transitions to Completed; download the PDF via WebDAV.
  6. FTP check (Method 4): list the remote folder and download the file; compare MD5 against the local buffer's hash.

Troubleshooting Matrix

Symptom Likely Cause Indicator (TMAIL_C / Runtime) Remediation
Mail not delivered DNS resolution failed STATUS indicates WSAHOST_NOT_FOUND class Hard-code SMTP IP, or check PROFINET DNS settings under CPU properties
Mail rejected at relay SMTP auth rejected STATUS indicates AUTH failure code Verify username/password; check relay requires AUTH LOGIN vs. PLAIN; check that the relay accepts the client IP
Mail accepted, attachment garbled Length mismatch DONE=TRUE, but Excel shows trailing nulls Set ATTACHMENT.LEN to the exact byte count, not the DB size
USB log not visible Wrong file system — Reformat to FAT32; Comfort >= V16 supports NTFS only with ET 200SP USB
Report job stuck at "Pending" Unified SMTP user not configured Runtime log: SMTP_HOST_EMPTY Open Settings -> Mail on the Unified runtime and complete the host field
TMAIL_C compile error "block not found" SMTP library not installed — Options -> Manage Libraries -> import "Communication -> SMTP"
FTP upload rejected Remote path missing FTP_CMD returns 5xx reply code Pre-create the folder or grant user create rights
HMI panel does not recognize USB stick Partition scheme GUID (GPT) — Reformat as MBR with single FAT32 partition
TLS handshake fails CPU firmware older than V4.4 TMAIL_C_SEC STATUS indicates handshake error Upgrade firmware or fall back to plain SMTP on port 25 within plant only
Mail sent but recipient cannot open CSV uses locale separator incompatible with recipient Excel — Embed sep=; on first line and use UTF-8 BOM
Specific STATUS codes returned by TMAIL_C and TMAIL_C_SEC vary across CPU firmware versions and TIA Portal releases. Always cross-reference the value against the TIA Portal online help entry for the SMTP block version installed in your project rather than relying on memorized codes.

Field-Commissioning Checklist

  • CPU firmware version verified against the TIA project (compare Online -> Diagnostics -> CPU -> Firmware).
  • SMTP credentials tested with a desktop mail client (Outlook, Thunderbird) before binding to the PLC.
  • Network firewall rules documented in the network diagram with rule ID, source, destination, and port.
  • USB stick model on the Bill of Materials; industrial-grade SanDisk or Siemens 6ES7648-0DC50-0AA0 recommended.
  • Report templates version-controlled with the HMI project; rebuild, do not edit in production.
  • Backup procedure for report archives — RDB files can be replayed in WinCC if the original CSV is corrupted.
  • Diagnostic tags mapped to a maintenance screen showing last STATUS, last DONE timestamp, and last error code.
  • Time synchronization active on CPU and panel (NTP or CP-side), so timestamps in the CSV match the historian's reference clock.

FAQ

Which S7-1200 firmware first supports TMAIL_C?

TMAIL_C is available on S7-1200 CPUs from firmware V4.2 onward, included in the "Communication -> SMTP" library that ships with TIA Portal V13 SP1. For TLS, use TMAIL_C_SEC on V4.4+ and TIA V15.1+.

Can a 7-inch Basic panel (KTP700 Basic) generate a formatted PDF report?

No. KTP Basic panels only export raw CSV logs to USB; the native report designer (PDF/XLSX/RTF output) requires a Comfort-class or Unified MTP panel.

What is the maximum attachment size for TMAIL_C?

The block does not impose a documented hard limit, but the SMTP relay typically accepts up to 25 MB. Above 32 KB the build time of the SMTP body becomes noticeable on the CPU; consider compressing the buffer or splitting the shift into multiple files for large archives.

Do I need an FTP server if I already email the report?

Not for an end user. FTP is useful when the destination is a historian or MES that polls a known directory rather than processing inbound mail. For consumer-grade networks, prefer email or SFTP from a Unified panel.

Where is the report designer in TIA Portal V20?

Project navigation -> HMI device -> Reports. Double-click "Add new report" to create a template, then add a report task under "Report tasks" to schedule it on a Unified runtime. See Siemens Support entry 109091876 and the WinCC Unified report-job documentation.

Back to blog