Exporting Siemens DB Declarations to Excel with Addresses

David Krause12 min read
SiemensTechnical ReferenceTIA Portal
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

Exporting Siemens DB Declarations to Excel with Addresses

When engineers copy a Siemens S7-300, S7-400, S7-1200, or S7-1500 data block (DB) declaration view out of TIA Portal or classic STEP 7 and paste it into Excel or a text file, the physical memory addresses (for example, DB1.DBX0.0, DB1.DBD4, DB1.DBW10) are dropped. Only the symbolic name, data type, initial value, and comment survive the clipboard transfer. This reference explains why the addresses are missing and documents every reliable workaround for getting address + name + type + comment rows out of the engineering tool into a spreadsheet while preserving the byte and bit offset.

1. Problem Statement and Engineering Context

The DB declaration view in TIA Portal lists three logical columns plus the offset column:

  • Name (symbolic identifier)
  • Data type (BOOL, INT, REAL, STRING, ARRAY, STRUCT, etc.)
  • Start value / initial value
  • Comment / remark
  • Offset (byte.bit or byte address)

The offset column is generated dynamically by the editor when the block is compiled and is not part of the textual declaration that is exchanged through the clipboard. When the user selects rows, presses Ctrl+C, and pastes into Excel or Notepad, only the four text columns are written. The physical offsets disappear.

Why this matters. The offset is required for any cross-reference, for HMI tag configuration, for OPC UA mapping, for Modbus/Profibus slot calculations, and for SCADA point databases. A DB list without offsets forces the engineer to reconstruct the memory layout manually — a slow and error-prone task on blocks with hundreds of tags.

2. Why the Address Column Is Lost on Copy/Paste

The DB declaration grid in TIA Portal is implemented as a structured editor view backed by the block's XML representation in the project tree. The visible offset column is computed at runtime from the layout of the preceding tags; it is not a stored property of each row. STEP 7 classic and TIA Portal both serialize DB declarations into an .scl or .db source file that contains only the symbolic structure — names, types, initial values, and comments. The offsets are assigned only when the compiler lays out the data block in the PLC's load memory.

Consequences:

  • Plain Ctrl+C / Ctrl+V to Excel or Notepad exports the textual source columns only.
  • Exporting the DB as an STL source yields the same textual source, again without offsets.
  • Only when the source is re-imported into the program editor and the project is compiled are the offsets regenerated.

3. Built-in Export Options Available in TIA Portal

TIA Portal V15 and later provides several export paths that retain varying amounts of metadata. The matrix below summarizes what each path includes.

Export path Menu location Offset included? Format Use case
PLC tag table export Project tree → PLC tags → Export No (symbolic only) CSV / XLSX External tag list, HMI import
Watch table export Watch table → right-click → Export No (symbolic only) CSV / TXT Online monitoring seed list
DB source export (SCL/STL) DB → right-click → Generate source from blocks No (compiled only on import) .scl / .db Source-controlled versioning
Cross-reference (offline) Project tree → Cross-reference Yes Built-in grid, copy/paste partial Address verification
Program info / project dump Project → Tools → Program information Yes Internal grid, no direct export Audit, documentation
PLC data archiving (recipe export) Online → Read DB to file No (values only) Binary .dat Recipe values, not symbols
Documentation / Print to PDF DB → Print Yes PDF via Microsoft Print to PDF Static documentation

4. Method 1 — Reconstruct Byte/Bit Addresses Manually in Excel

The fastest documented workaround, used in the field when only a one-off export is needed, is to paste the four text columns into Excel and then build the offset column with CONCATENATE formulas. The approach assumes a flat (non-nested) DB.

4.1 Procedure

  1. Open the DB in TIA Portal, switch to the Declaration view (not the Data view).
  2. Select the entire grid with Ctrl+A and copy with Ctrl+C.
  3. Open Excel and paste into sheet Raw starting at cell A1. Excel places Name in A, Data type in B, Initial value in C, Comment in D.
  4. Insert two helper columns: ByteOffset (E) and BitOffset (F).
  5. Fill column E from 0 upward using the type sizes shown in the table below.
  6. Fill column F from 0 upward only on BOOL rows; leave blank for non-BOOL rows.
  7. Add column G Address with formula =CONCATENATE("DB",1,".DB") extended for the access size.

4.2 Type-Size Lookup Table

Data type Size (bytes) Bit access syntax Byte access syntax Word/DWord access syntax
BOOL 1 (one bit) DBX<b>.<bit> DBB<b>
BYTE 1 DBB<b>
CHAR / SINT / USINT 1 DBB<b>
WORD / INT / UINT 2 DBW<b>
DWORD / DINT / UDINT / REAL / TIME 4 DBD<b>
LWORD / LINT / ULINT / LREAL / LTIME / DTL 8 DBL<b>
STRING[n] n+2 (header bytes included) Byte stream starting at DBB<b>
WSTRING[n] 2·(n+2) Byte stream starting at DBB<b>
ARRAY / STRUCT Sum of members

4.3 Sample Formulas (Excel)

For a BOOL row at byte n, bit m:

=CONCATENATE("DB",1,".DBX",E2,".",F2)

For a non-BOOL row of size s bytes starting at byte n:

=IF(B2="BOOL",CONCATENATE("DB",1,".DBX",E2,".",F2),IF(s=1,CONCATENATE("DB",1,".DBB",E2),IF(s=2,CONCATENATE("DB",1,".DBW",E2),IF(s=4,CONCATENATE("DB",1,".DBD",E2),CONCATENATE("DB",1,".DBB",E2,"..",E2+s-1)))))

Drill a VLOOKUP against the size lookup table on column B to make the size explicit instead of hard-coded.

Limitation. This method is reliable only on flat DBs with no nested STRUCT or ARRAY elements that are themselves composed of multiple primitive tags. For nested layouts, the bit counter and the byte counter must be reset at the start of each STRUCT and incremented per nested element.

5. Method 2 — Use the PLC Tag Table as a Spreadsheet Bridge

The PLC tag table in TIA Portal exports cleanly to CSV. Although it does not include the byte offset, it can serve as a master list for cross-referencing the actual offsets obtained from the cross-reference window.

  1. In the project tree, expand PLC tags and double-click Default tag table.
  2. Add all DB tags of interest as DB operand entries using the format "DBName".TagName.
  3. Right-click inside the table and choose Export → CSV. Choose UTF-8, semicolon separator for German-locale workstations, comma for English.
  4. Open the CSV in Excel; columns delivered: Name, Path, Operand, Data type, Comment.
  5. Use the cross-reference window (next section) to attach addresses.

The default tag table exported through Project → Export PLC tags is also accepted by SIMATIC HMI panels and WinCC Unified for tag import. This makes it a useful pivot format even when the offset column is missing.

6. Method 3 — Cross-Reference Window and Copy with Offsets

The Cross-reference editor in TIA Portal (menu Project → Cross-reference) is the only built-in view that contains both the symbolic name and the absolute address. It can be exported through the standard Windows clipboard as a tab-separated block.

  1. Compile the project (Project → Compile all) so cross-references are populated.
  2. Open Project tree → Cross-reference.
  3. Filter the Used in column to the DB of interest.
  4. Select all rows, Ctrl+C, and paste into Excel.
  5. Use Excel Text to Columns with tab delimiter.

Typical columns delivered by cross-reference:

  • Object
  • Symbol
  • Address (for example, DB1.DBX0.0)
  • Type
  • Access (read/write)
  • Used in / Location
The cross-reference view includes only symbols that are actually referenced in the program code. Unused DB tags (declared but never read or written) will not appear. Add a dummy reference in OB1 if a complete dump is required.

7. Method 4 — STL/SCL Source Export and Re-Compile Round-Trip

In classic STEP 7 (V5.x), the recommended workflow for capturing the source with type information is:

  1. Select the DB in SIMATIC Manager.
  2. Right-click → Generate source → select STL or SCL source files.
  3. Open the generated .scl / .awl file.
  4. The source contains only declarations: Name : TYPE := initial; statements.

To regenerate offsets after editing, choose File → Compile in the source editor. The compiled block will then display offsets, which can be copied individually by selecting the offset cell only.

This round-trip is the only way to guarantee that the offsets match a freshly compiled project after a type change. It is the procedure Siemens support recommends for source-controlled DB libraries that must remain binary-identical across TIA Portal versions.

8. Method 5 — Print to File (PDF) and OCR / Table Extraction

When no scripting is available and a one-shot document is acceptable, TIA Portal's built-in Print command renders the declaration view with the offset column visible. Selecting Microsoft Print to PDF as the printer produces a multi-page PDF. The PDF can be opened in Excel via Data → Get Data → From File → From PDF on Microsoft 365, which converts the tabular declaration into rows. The technique is reliable for simple blocks; nested structs occasionally break the row alignment.

9. Script-Based Automation for Repetitive Exports

When the same DB layout must be exported weekly (for example, to feed an OPC UA namespace generator or a SCADA point database), use one of the automation paths below.

9.1 TIA Portal Openness API (V15.1+)

The TIA Portal Openness API exposes the PlcBlock and PlcTagTable interfaces. A C# or VB.NET script can iterate through every PlcTag in the DB and dump Name, Address, Data type, Comment to CSV. The API requires a TIA Portal installation with the Openness option installed and a valid license key. The Openness API is documented in the Siemens Industry Online Support under the entry ID 109776038.

9.2 Python with the snap7 Library

Python scripts using the snap7 library cannot read the offline DB declaration, but they can read the actual runtime data. Combined with a parsed .scl source file, a script can build an offset dictionary automatically:

from snap7 import client
c = client.Client()
c.connect('192.168.0.1', 0, 1)
data = c.db_read(1, 0, 256)   # DB1, start 0, length 256 bytes
print(data.hex())

The offline layout comes from a Python parser of the .scl source file. Combine the two to produce an address, name, type, value, comment CSV.

9.3 VBA Macro Inside Excel

For environments without TIA Openness, a VBA macro can read a tab-delimited clipboard paste and rebuild the offset column by walking the rows and tracking an internal byte counter. The same logic as the manual CONCATENATE formula above, but in code so it scales to thousands of tags.

10. Step-by-Step: Reliable One-Shot Export with Offsets

  1. Compile the project (Project → Compile all).
  2. Open the DB. Confirm the Offset column is visible: right-click the header → Show/hide → Offset.
  3. Switch to the Cross-reference editor. Filter to the DB. Ctrl+A, Ctrl+C.
  4. Paste into Excel sheet Symbols. Use Text to Columns with tab delimiter.
  5. Open the DB declaration view. Ctrl+A, Ctrl+C. Paste into sheet Decl.
  6. In sheet Merged, use VLOOKUP keyed on the symbolic name to merge address (from Symbols) with type and comment (from Decl).
  7. Save as .xlsx and also Save As → CSV (Comma delimited) for downstream tools that require CSV.

11. Verification

After producing the export, verify that the offsets match the runtime image of the DB:

  1. Go online with the PLC (Online → Go online).
  2. Open the DB and switch to Data view.
  3. Read the first three tags of each data type and write their offsets down.
  4. Compare with the spreadsheet. Any mismatch indicates either an out-of-date cross-reference (re-compile) or a tag that the cross-reference filtered out (add a reference and re-export).
  5. Cross-check the byte count: the highest byte address plus the size of the last tag must equal the Length field of the DB online (Properties → Information).

12. Troubleshooting Matrix

Symptom Probable cause Remedy
Paste shows only three columns, no offset Offset column hidden in editor view Right-click header → Show/hide → Offset, then copy again
Cross-reference is empty Project not compiled Project → Compile all → Software (rebuild all)
Cross-reference missing some tags Tags never referenced in code Add // dummy reference in OB1 or use Program info instead
CSV shows German number format (1,23 instead of 1.23) Locale mismatch Re-export with explicit decimal separator, or use Data → Text to Columns in Excel
Openness API throws LicenseException Openness license not installed Install via TIA Portal Setup → Options → TIA Portal Openness
STL source export omits new tags Source not regenerated Right-click block → Generate source from blocks → overwrite
Excel CONCATENATE overflows at byte 9999 DB larger than 10 KB Use INT64 logic in column E; address syntax remains DBW/DBD for any value > 255
STRUCT tags show wrong offset Manual counter not reset at struct boundary Use Openness API or TIA cross-reference; do not hand-roll on nested DBs

13. Reference URLs and Documentation

Why does Ctrl+C in the DB declaration view drop the address column?

The offset column is generated at runtime by the editor and is not part of the textual declaration. Only Name, Data type, Initial value, and Comment are copied. Re-enable the column with right-click on the header → Show/hide → Offset if it is missing from view, and use the cross-reference editor or TIA Openness to extract offsets.

What is the fastest way to get offsets out of a single flat DB?

Compile the project, open Cross-reference, filter to the DB, select all rows, copy with Ctrl+C, and paste into Excel with Text to Columns using tab delimiter. Cross-reference is the only built-in view that includes the absolute byte/bit address alongside the symbolic name.

Can I export a DB layout to CSV directly?

TIA Portal exports the PLC tag table to CSV but without offsets. The DB declaration view supports Print to PDF, which Excel 365 can convert to rows via Data → Get Data → From File → From PDF. For a clean CSV with offsets, use TIA Openness to walk the PlcBlock model and write the CSV programmatically.

How are offsets calculated for BOOL arrays and STRUCT members?

Offsets are assigned by the compiler in declaration order. BOOLs pack 8 per byte starting at the current byte boundary; a new byte starts on the next addressable unit for the next non-BOOL type. STRUCTs are laid out as if their members were declared in the parent block; arrays repeat the member layout N times. The manual Excel reconstruction method breaks down on nested structs — use TIA Openness for those.

Does the export include the comments for each tag?

Yes, the four-column paste from the declaration view includes the comment column. The cross-reference paste does not include comments, so merge both views with a VLOOKUP keyed on the symbolic name if comments are required in the final CSV or Excel workbook.

Back to blog