Are "tv" and "tc" the names of ranges in your Excel file? In Excel 2010 they should be in the listing that pops up when you click on Name Manager under the Formulas tab (and in earlier versions there's a menu item to look at this listing). Or if you type a name such as "tv" into the left side of the formula bar (where it commonly says something like "A1") then if the range exists, Excel will highlight it.
If they are definitely the names of ranges according to these tests, then can you post the Excel file?
Bob Fourer
From: am...@googlegroups.com [mailto:am...@googlegroups.com]
On Behalf Of Daji
Sent: Thursday, January 24, 2013 2:04 AM
To: am...@googlegroups.com
Subject: [AMPL 6509] Why I can't read data from excel?
In my .dat file. I have these lines.
table travelT IN "ODBC" "HAPPDJ4.xlsx" "tv" :
[i ~ NODES], {j in NODES} < traveltime[i,j] ~ (j)>;
table travelC IN "ODBC" "HAPPDJ4.xlsx" "tc" :
[i ~ NODES], {j in NODES} < travelcost[i,j] ~ (j)>;
read table travelT;
read table travelC;
When I try to run it, it gives me the following error. However, I check many times I do have "tv" and "tc" in my excel file. Can anyone help? Thanks.
ampl: include HAPPDJ4.run;
Error at _cmdno 3 executing "read_table" command
(file HAPPDJ4.dat, line 42, offset 896):
Error reading table travelT with table handler odbc:
Table tv does not appear in "HAPPDJ4.xlsx".
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ampl/-/Wj62rTVzmhoJ.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.
In your Excel file, "tv" and "tc" are the names of sheets, not the names of ranges. To name a range, highlight all the cells of a table that will be read into AMPL, then type the table name (such as "tv" or "tc") into the box at the far left of the formula bar; or in Excel 2010 you can also use the Name Manager under the Formulas tab.
On Behalf Of Daji
Sent: Tuesday, January 29, 2013 5:19 PM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 6533] Why I can't read data from excel?
This is the excel file.