Linking a Lookup Table to a Spreadsheet

You link a Lookup Table to a spreadsheet by selecting ”MS-Excel” from the Data Source A source of data external to your GoldSim model that can be automatically imported into GoldSim elements. External data sources are either spreadsheets, text files, databases or DLLs. field at the bottom of the Lookup Table dialog:

When you do so, a new tab (Excel) is added to the dialog that allows you to define the properties of the spreadsheet link:

You must first enter the name of a Microsoft Excel spreadsheet file by pressing the Options >> button. This will provide options for either selecting an existing file, or creating (and then selecting) a new file.

Note: If you select a file in the same directory as (or a subdirectory below) your GoldSim .gsm file, GoldSim will subsequently display just a local path. If you select a file in a directory above your .gsm file, it will display the full path.

Once you have selected a file, you can subsequently use the Options >> button to select a different file. You can also use the Options>> button to open the selected file in Excel.

Note: GoldSim supports both .xlsx and .xls Excel files. Note that GoldSim does not officially support versions of Excel prior to Excel 2010.
Warning: You should never try to open a spreadsheet that is linked to GoldSim while a simulation is running. In addition, prior to running a GoldSim model that is linked to a spreadsheet, all referenced spreadsheets should be closed. If you try to interact with a spreadsheet that is being used by GoldSim during a simulation, all interaction with the spreadsheet is blocked by GoldSim. However, under some circumstances this may not be possible and could lead to errors. Hence, as a general rule, you should not use Excel while a GoldSim model that references Excel is running.

It is easiest to understand how to define the spreadsheet linkage by considering 1-D, 2-D and 3-D tables separately.

Defining 1-D Tables

Defining 2-D Tables

Defining 3-D Tables

Note: When data is imported from Excel into a Lookup Table, it is assumed that the values for the independent and dependent variables in Excel are in the same units as those specified in the Lookup Table dialog.
Note: When data is imported from Excel into a Lookup Table, it will stop the import and report an error if the values of the independent variables do not increase monotonically as you move downward/across the table. That is, unlike the case when you enter the data directly, GoldSim will not automatically sort the entries.

GoldSim automatically imports data from the spreadsheet at the start of a simulation if either 1) any of the properties on the Excel tab have been modified; or 2) the Excel file itself has been changed since the last import. You can also import data manually at any time prior to running a simulation (e.g., so you can view it) by pressing the Import Data button in the Excel tab.

Note: When you link a Lookup Table to a spreadsheet, the Edit Data... button changes to View Data.... If you press this button to access the dialog displaying the data, you will note that they are no longer editable. Once you are linked to a spreadsheet in this way, you can not edit the data manually unless you change Data Source back to “None”. When you do so, GoldSim keeps the imported data and makes it editable.

If you want to ensure that you do not import data from the spreadsheet that has been inadvertently edited since you last imported the data, you can choose to “Lock onto” a spreadsheet file (by checking “Lock onto selected file” from the Options>> button). If you are locked onto a file, GoldSim will not allow the simulation to run if the file has been modified in any way (the file is set to read only when it is locked onto). In order to run a simulation with a changed file, you must first remove the lock (by clearing “Lock onto selected file” from the Options>> button).

The example file (ImportTable.gsm) in the General Examples/LookupTable folder of your GoldSim directory (accessed by selecting File | Open Example... from the main menu) illustrates how the Lookup Table data can be imported from a spreadsheet.