×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 24352635, Entry date: 01/05/2007
(12)
Rate

How do you import an Excel list with STEP 7 variables into a data block?

  • Entry
  • Associated product(s)

Instructions:
If you wish to import variables from an Excel list into your STEP 7 project, the Excel list has to be saved beforehand in the format "Formatted Text (Space delimited)(*.prn)". The file is then inserted into your source folder as an external STL source. The procedure for this is described in the table below:
 

No. Procedure
1 Open MS Office Excel and enter the tags for the data block, as shown in Fig. 01. Use one column for the names of the tags and another for the data types:


Fig. 01
2 Initial values
If you don't require initial values for your data block, skip this step and proceed to No. 3. Otherwise, enter the initial values for your tags, as shown in Fig. 02 (column E).


Fig. 02
3 We would advise you to enter the following columns for your tags in the Excel list;
  • a column with colons (":") next to the column with the tag names,
  • a column with the assignments (":=") for the tags with the initial values beside the column for the data types
  • and a column with the semicolon (";"), as shown in Fig. 02.

These syntax characters can also be added later in the source for the data block. The assignment for each tag with a data type entails a colon, and the assignment with an initial value entails the string ":=". Each instruction must be closed with a semicolon, such as the assignment of the tag "Motor_On: bool:= false;".

4 Using "File > Save as...", save your Excel list in a folder on your hard disk as a
  • "Formatted Text (Space delimited)(*.prn)" file type.

Therefore, the filename should be a ".prn" type.


Fig. 03
5 Click OK to acknowledge the message
  • "The selected file type does not support workbooks with multiple sheets."

.

6 Click Yes to acknowledge the message
  • "<Filename>.prn may contain features which are no compatible with Formatted Text (Space delimited).
    Would you like to save the workbook in this format?"

.

7 Then go to your folder and select the file which you have saved there. Right-click it. This opens the pop-up menu. Click "Rename" and change the file type from
  • <Filename>.prn to <Filename>.awl.

Click Yes to confirm the message which then appears.

8 Import the AWL file which has been created into your STEP 7 project. To do this, select the source folder for your STEP 7 project and open the "Insert External Source" dialog in the SIMATIC Manager via "Insert > External source...". As shown in Fig. 04, select the created AWL file from your storage path and click "Open".


Fig. 04

The AWL file is now imported as an external source.

9 Open the imported AWL source in the source folder and insert your data block template for your tags via the commend "Insert > Block Template > DB" in the menu.


Fig. 05
10 Delete the comments (green text) which are surplus to requirements and drag & drop your tags between "STRUCT" and "END_STRUCT". Adapt the number of the data block and also delete the tag "b0" from the declaration and the instruction "b0:= b#16#01" between "BEGIN" and "END_DATA_BLOCK".


Fig. 06
11 Save and compile the source data block via the disk and compiler icons or via "File > Save" and "File > Compile".


Fig. 07

Once the data block has been successfully compiled, the data block (in this case DB12) is generated and saved in the block folder.

12 The data block is now available for further processing within your STEP 7 project.


Fig. 08
  ( 18 KB )

Note:
For further information, for example, on how to export a source data block from an Excel list, on how to edit the current values and on how to import the edited Excel list back into the STEP 7 project, also refer to our entry entitled

  • "What is the significance of the initial and actual values of a data block?"
    Entry ID: 837001

Keywords:
Data transfer

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.