EXCEL-GAMS.EASIEST WAY?

Dear all

pleas tell me what is the easiest way to transfer data between Excel and GAMS (writing results from GAMS to Excel and reading data from Excel to GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

hi babak
see the gdx manual under gdx re
Renger

Sent from my iPhone

Am 23.07.2011 um 16:49 schrieb Babak Saleck Pay :

Dear all

pleas tell me what is the easiest way to transfer data between Excel and GAMS (writing results from GAMS to Excel and reading data from Excel to GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

I use this one:

$call =xls2gms @“C:\Model Data\xls2gms_data.txt”


Lena



On Sat, Jul 23, 2011 at 10:49 AM, Babak Saleck Pay wrote:


Dear all

pleas tell me what is the easiest way to transfer data between Excel and GAMS (writing results from GAMS to Excel and reading data from Excel to GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thank you dear Lena and Renger.

Bests

On Sat, Jul 23, 2011 at 9:27 PM, Renger van Nieuwkoop wrote:

hi babak
see the gdx manual under gdx re
Renger

Sent from my iPhone

Am 23.07.2011 um 16:49 schrieb Babak Saleck Pay :

Dear all

pleas tell me what is the easiest way to transfer data between Excel and GAMS (writing results from GAMS to Excel and reading data from Excel to GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.

--
Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

--
To post to this group, send email to <gamsworld@googlegroups.com>.
To unsubscribe from this group, send email to <gamsworld+unsubscribe@googlegroups.com>.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com



On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

\

HI!

Please create in EXCEL button and put inside script


Dim bb As String
Dim aa As String

Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text

Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”

Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”

i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”

For i = 1 To 6
j = Row_position(i)
If i 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i

aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j

For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa

Next j


'========================================================================
f.Close

\


This script transport data from result1.txt to spreadsheet “result” in
EXCEL

How to make txt file in GAMS You can found in guide of GAMS

30.07.2011, 12:22, “Alireza Bahari” :

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com

On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

result_1.txt (2.88 KB)

thank you Andre
it was really good and I can learn from it.

do you have any document that explain these kind of projects, for example using VB to pass data to GAMS?

For excel ( passing data from excel to GAMS) the file that Alireza sent was very good for me and I learn much about it.

bests

On Sun, Jul 31, 2011 at 1:33 AM, Savitsky Andre wrote:

HI!

Please create in EXCEL button and put inside script


Dim bb As String
Dim aa As String

Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text

Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”

Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”

i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”

For i = 1 To 6
j = Row_position(i)
If i 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i

aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j

For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa

Next j


'========================================================================
f.Close

\


This script transport data from result1.txt to spreadsheet “result” in
EXCEL

How to make txt file in GAMS You can found in guide of GAMS

30.07.2011, 12:22, “Alireza Bahari” :

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com

On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


With kindly regards!
Andre


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

This is why Gams developer gdxxrw so we don’t have to write code like this…

Sent from my iPhone

Am 30.07.2011 um 23:03 schrieb Savitsky Andre :

HI!

Please create in EXCEL button and put inside script


Dim bb As String
Dim aa As String

Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text

Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”

Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”

i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”

For i = 1 To 6
j = Row_position(i)
If i > Worksheets(“Results”).Cells(j, 2) = “Name of lake”
End If
If i = 4 Then
Worksheets(“Results”).Cells(j, 2) = “Name of canal”
End If

If i = 5 Then
Worksheets(“Results”).Cells(j, 1) = “Name of N1”
Worksheets(“Results”).Cells(j, 2) = “Name of N”
End If

If i = 6 Then
Worksheets(“Results”).Cells(j, 2) = “Provinces”
End If

Worksheets(“Results”).Cells(j, 3) = “Jan”
Worksheets(“Results”).Cells(j, 4) = “Feb”
Worksheets(“Results”).Cells(j, 5) = “Mar”
Worksheets(“Results”).Cells(j, 6) = “Apr”
Worksheets(“Results”).Cells(j, 7) = “May”
Worksheets(“Results”).Cells(j, 8) = “Jun”
Worksheets(“Results”).Cells(j, 9) = “Jul”
Worksheets(“Results”).Cells(j, 10) = “Aug”
Worksheets(“Results”).Cells(j, 11) = “Sep”
Worksheets(“Results”).Cells(j, 12) = “Oct”
Worksheets(“Results”).Cells(j, 13) = “Nov”
Worksheets(“Results”).Cells(j, 14) = “Dec”

Next i

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject(“Scripting.FileSystemObject”)
Set f = fs.OpenTextFile(Path_output1, ForReading, TristateUseDefault)
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i

aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j

For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa

Next j

'========================================================================
f.Close


This script transport data from result1.txt to spreadsheet “result” in
EXCEL

How to make txt file in GAMS You can found in guide of GAMS

30.07.2011, 12:22, “Alireza Bahari” :

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com

On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


With kindly regards!
Andre


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


\

Hi
i have no such documents, but i can help you. if you have any problem,
you can call me.
09192902179
best

On 7/31/11, Renger van Nieuwkoop wrote:

This is why Gams developer gdxxrw so we don’t have to write code like
this…

Sent from my iPhone

Am 30.07.2011 um 23:03 schrieb Savitsky Andre :

HI!

Please create in EXCEL button and put inside script


Dim bb As String
Dim aa As String

Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text

Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”

Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”

i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”

For i = 1 To 6
j = Row_position(i)
If i > >> Worksheets(“Results”).Cells(j, 2) = “Name of lake”
End If
If i = 4 Then
Worksheets(“Results”).Cells(j, 2) = “Name of canal”
End If

If i = 5 Then
Worksheets(“Results”).Cells(j, 1) = “Name of N1”
Worksheets(“Results”).Cells(j, 2) = “Name of N”
End If

If i = 6 Then
Worksheets(“Results”).Cells(j, 2) = “Provinces”
End If

Worksheets(“Results”).Cells(j, 3) = “Jan”
Worksheets(“Results”).Cells(j, 4) = “Feb”
Worksheets(“Results”).Cells(j, 5) = “Mar”
Worksheets(“Results”).Cells(j, 6) = “Apr”
Worksheets(“Results”).Cells(j, 7) = “May”
Worksheets(“Results”).Cells(j, 8) = “Jun”
Worksheets(“Results”).Cells(j, 9) = “Jul”
Worksheets(“Results”).Cells(j, 10) = “Aug”
Worksheets(“Results”).Cells(j, 11) = “Sep”
Worksheets(“Results”).Cells(j, 12) = “Oct”
Worksheets(“Results”).Cells(j, 13) = “Nov”
Worksheets(“Results”).Cells(j, 14) = “Dec”

Next i

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject(“Scripting.FileSystemObject”)
Set f = fs.OpenTextFile(Path_output1, ForReading, TristateUseDefault)
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i

aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j

For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa

Next j

'========================================================================
f.Close


This script transport data from result1.txt to spreadsheet “result” in
EXCEL

How to make txt file in GAMS You can found in guide of GAMS

30.07.2011, 12:22, “Alireza Bahari” :

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com

On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel
and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


With kindly regards!
Andre


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


\

Hi.
it’s kind of you.

thanks.

On Sun, Jul 31, 2011 at 8:32 PM, ali wrote:

Hi
i have no such documents, but i can help you. if you have any problem,
you can call me.
09192902179
best

On 7/31/11, Renger van Nieuwkoop wrote:

This is why Gams developer gdxxrw so we don’t have to write code like
this…

Sent from my iPhone

Am 30.07.2011 um 23:03 schrieb Savitsky Andre :

HI!

Please create in EXCEL button and put inside script


Dim bb As String
Dim aa As String

Dim temp As String
Dim how_many As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Name As String
Dim Result(12) As Double
Dim Row_position(10) As Integer
Dim Path_output As String
Dim Path_output1 As String
Dim Path_output2 As String
Dim Path_output3 As String
Dim Path_output4 As String
Path_output = Worksheets(“Main”).TextBox2.Text

Path_output1 = Path_output & "" & “result_1.txt”
Path_output2 = Path_output & "" & “result_2.txt”
Path_output3 = Path_output & "" & “result_3.txt”
Path_output4 = Path_output & "" & “result_4.txt”

Row_position(1) = 10
Row_position(2) = 20
Row_position(3) = 30
Row_position(4) = 50
Row_position(5) = 110
Row_position(6) = 200
i = 1
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Volume”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = “at the end”
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "of month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “in MAF”
i = 2
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “End of the”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "month "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = “lake”
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “level (metr)”
i = 3
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Power”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "generation "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "in lake "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(Th mgvth)”

i = 4
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = “Canal diversion”
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = "at the canal "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = "head "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 5
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Flow From "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " node N1 to "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " node N "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “(MAF)”

i = 6
Worksheets(“Results”).Cells(Row_position(i) - 1, 2) = " Spliting "
Worksheets(“Results”).Cells(Row_position(i) - 1, 3) = " water "
Worksheets(“Results”).Cells(Row_position(i) - 1, 4) = " (MAF) "
Worksheets(“Results”).Cells(Row_position(i) - 1, 5) = “”

For i = 1 To 6
j = Row_position(i)
If i > Worksheets(“Results”).Cells(j, 2) = “Name of lake”
End If
If i = 4 Then
Worksheets(“Results”).Cells(j, 2) = “Name of canal”
End If

If i = 5 Then
Worksheets(“Results”).Cells(j, 1) = “Name of N1”
Worksheets(“Results”).Cells(j, 2) = “Name of N”
End If

If i = 6 Then
Worksheets(“Results”).Cells(j, 2) = “Provinces”
End If

Worksheets(“Results”).Cells(j, 3) = “Jan”
Worksheets(“Results”).Cells(j, 4) = “Feb”
Worksheets(“Results”).Cells(j, 5) = “Mar”
Worksheets(“Results”).Cells(j, 6) = “Apr”
Worksheets(“Results”).Cells(j, 7) = “May”
Worksheets(“Results”).Cells(j, 8) = “Jun”
Worksheets(“Results”).Cells(j, 9) = “Jul”
Worksheets(“Results”).Cells(j, 10) = “Aug”
Worksheets(“Results”).Cells(j, 11) = “Sep”
Worksheets(“Results”).Cells(j, 12) = “Oct”
Worksheets(“Results”).Cells(j, 13) = “Nov”
Worksheets(“Results”).Cells(j, 14) = “Dec”

Next i

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject(“Scripting.FileSystemObject”)
Set f = fs.OpenTextFile(Path_output1, ForReading, TristateUseDefault)
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmm
Next j
mmm:
Worksheets(“Results”).Cells(Row_position(1) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(1) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmm
Next j
mmmm:
Worksheets(“Results”).Cells(Row_position(2) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(2) + i, 2 + j) = Result(j)
Next j
Next i
'========================================================================
a = f.ReadLine
'========================================================================
a = f.ReadLine
how_many = f.ReadLine
a = f.ReadLine
For i = 1 To how_many
a = f.ReadLine
b = Split(a)
Name = b(0)

counter = 0
For j = 1 To 255
temp = b(j)
If Len(temp) > 0 Then
counter = counter + 1
Result(counter) = Val(temp)
End If
If counter > 11 Then GoTo mmmmm
Next j
mmmmm:
Worksheets(“Results”).Cells(Row_position(3) + i, 2) = Name
For j = 1 To 12
Worksheets(“Results”).Cells(Row_position(3) + i, 2 + j) = Result(j)
Next j
Next i

aa = f.ReadLine
For j = 1 To 7
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 10) = bb
Worksheets(“Results”).Cells(1 + j, 11) = aa
Next j

For j = 1 To 4
bb = f.ReadLine
aa = f.ReadLine
Worksheets(“Results”).Cells(1 + j, 12) = bb
Worksheets(“Results”).Cells(1 + j, 13) = aa

Next j

'========================================================================
f.Close


This script transport data from result1.txt to spreadsheet “result” in
EXCEL

How to make txt file in GAMS You can found in guide of GAMS

30.07.2011, 12:22, “Alireza Bahari” :

If you Like, i can hellp you. tell me abaou your project in ditail
alireza.b.1201@gmail.com

On Jul 23, 6:49 pm, Babak Saleck Pay wrote:

Dear all

pleas tell me what is the easiest way to transfer data between Excel
and
GAMS (writing results from GAMS to Excel and reading data from Excel to
GAMS).
Pleas help me as I am in hurry for my project.

Thank you in advance.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


With kindly regards!
Andre


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.