Pasting in Data from Excel

You should be able to paste data into LINGO from any application that supports a cut command. For illustration purposes, we will show how to paste data from an Excel worksheet into a LINGO model. Recall our staff scheduling model from Using Sets, which is reproduced here with the data for the REQUIRED attribute omitted from the data section.

SETS:

  DAYS / MON TUE WED THU FRI SAT SUN/:

   REQUIRED, START;

ENDSETS

 

DATA:

  REQUIRED = <data omitted>;

ENDDATA

 

MIN = @SUM( DAYS( I): START( I));

 

@FOR( DAYS( J):

  @SUM( DAYS( I) | I #LE# 5:

     START( @WRAP( J - I + 1, 7)))

        >= REQUIRED( J)

);

Suppose your staffing requirements data is maintained in an Excel worksheet that resembles the following:

page242xp

To paste the staffing requirements data from Excel into the LINGO model above, follow these steps:

1.Select the range containing the data (C3:I3) by placing the cursor on the C3 cell, press and hold down the left mouse button, drag the mouse to cell I3, then release the mouse button.
2.Select the Copy command from Excel's Edit Menu.
3.Click once on the LINGO model window.
4.Place the LINGO cursor directly to the right of the data statement: REQUIRED =.
5.Select the Paste command from LINGO's Edit menu.
6.The data should now appear in the LINGO model as follows:

DATA:

  REQUIRED = 20 16 13 16 19 14 12;

ENDDATA

You may need to adjust the font of the data to your liking. You can use the Edit|Select Fontcommand in LINGO to accomplish this. Your model now has the required data and is ready to be solved. Note that LINGO also has features that allow you to import data directly from Excel. See Interfacing with Spreadsheets for more information.