Question: Can't figure out how to export loops to excel.

Here is my code:

restart:
with(LinearAlgebra):with(plots):with(ExcelTools):
n:=0.8:    e:=1:   h2:=0.01:
for N from 20 by 10 to 100 do
for b from 0.01 by 0.05 to 0.26 do
for h from 0.02 by 0.02 to 0.2 do
for h1 from 0.015 by 0.015 to 0.105 do
  A1:=proc(N::posint,b1,e1,h0,h11,h21) local M;
      M:=Matrix(N,(i,j)->if i=j then e elif abs(i-j)=1 then h else 0 fi);
      M[1,2]:=h1;M[2,1]:=h1;M[N,N-1]:=h2;M[N-1,N]:=h2;M[N,N]:=e-b;M
  end proc:
  B1:=A1(N,e,b,h,h1,h2):
  p2:=Eigenvectors(B1,output='list'):
  for i from 1 by 1 to N do en1[i]:=Re(p2[i][1]); od:
  for j from 1 by 1 to N do
for i from 1 by 1 to N do
  tt[i][j]:=Re(p2[i][3][1][j]);
  if abs(tt[i][j])>n
     then
        t3:=i;
        energ:=Re(p2[t3][1]);
     else
        energ:=0;
        t3:=0; fi;
  if t3<>0
     then
        t4:=j;  
        occ:=Re(p2[t3][3][1][t4]);
     else
        occ:=0;
  fi;
    od;od;
  dat:=Array([N,h1,occ]):
  if occ<>0 then print(dat); fi:
od: od: od: od:

From here the print command in the last line needs to be replaced with some sort of export command.  The problem I am having is that when I do any sort of Export(dat,"Datafile.xls") command, the array get exported but then immediately overwritten by the next iteration.  Is there a way to export a loop to different location in an excel worksheet for each iteration? 

Thank you so much for any help you can give!

-Nathan

Please Wait...