Embedding Excel Sheets in LINGO

Just as you can embed a LINGO model into Excel, you can reverse the process and embed an Excel sheet in a LINGO model. To illustrate this, load the STAFFOLE model from the SAMPLES subdirectory into LINGO. Once again, this is our familiar staff scheduling model and it appears as follows:

page285xp

Model: STAFFOLE

This model reads data from and writes the solution to the Excel file STAFFOLE.XLS. To make our lives easier, it would be nice to embed this spreadsheet in the LINGO model to avoid having to load it into Excel each time we needed to work with our model. To do this, select the Edit|Insert New Object command in LINGO. You will be presented with the dialog box:

page286xp

Click on the Create from File button, enter the spreadsheet file name in the File field, click on the Link checkbox, and then press the OK button.

Your LINGO model should now appear as:

page287xp

The data spreadsheet is now embedded at the top of the LINGO document. You can easily edit the spreadsheet by double-clicking on it. When you save the LINGO model, the link to the Excel file will be saved as well.

At this point, go ahead and optimize the model by selecting the Solver|Solve command. When LINGO has finished solving the model, you should see the following:

page288xp

The optimal solution now appears in the embedded spreadsheet and the graphs of the solution have been updated.