How do you import an Excel list with STEP 7 variables into a data block?
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:
|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:|
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).
|3||We would advise you to enter the following columns for your tags in the Excel list;
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
Therefore, the filename should be a ".prn" type.
|5||Click OK to acknowledge the message
|6||Click Yes to acknowledge the message
|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
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".
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.|
|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".|
|11||Save and compile the source data block via the disk and compiler icons or via "File > Save" and "File > Compile".
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.|
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