求助:下列程序有点问题
通用报表打印程序.rar
(62.36 KB)
下列程序有点问题,提示:字符串太长,不能容纳。请高手指教,万分感谢!!!
Set Talk Off
hh1=Printstatus()
Set Print On
Do While.Not. hh1
? "打印机未准备好,请准备好打印机"
hh1=Printstatus()
Enddo
Set Talk Off
Set Device To Print
Clear
a1=Getfile("dbf")
Use "&a1"
n1=Fcount()
Dimension a(n1) && 定义一个存放字段名的数组
Dimension b(n1) && 定义一个存放字段宽度的数组
k=1
Do While k<=n1
a(k)=Field(k)
k=k+1
Enddo
w=1
Do While w<=n1
b(w)=Fsize(a(w))
b(w)=b(w)+2
w=w+1
Enddo
Do While .Not. Eof()
r1=1 && 显示表头的第一行
m=1
col1=1
Do While m<=n1
If m=1
@r1,col1 Say "┌"+Replicate("─",b(m))
Else
If m=n1
@r1,col1 Say "┬"+Replicate("─",b(m))+"┐"
Else
@r1,col1 Say "┬"+Replicate("─",b(m))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
m=1 && 显示字段名行
col1=1
Do While m<=n1
If m=1
@r1+1,col1 Say "│" +Substr(a(m),1,b(m))+Replicate(" " ,(b(m)-Len(a(m))))
Else
If m=n1
@r1+1,col1 Say "│" +Substr(a(m),1,b(m))+Replicate(" " ,(b(m)-Len(Substr(a(m),1,6))))+"│"
Else
@r1+1,col1 Say "│" +Substr(a(m),1,b(m))+Replicate(" " ,(b(m)-Len(Substr(a(m),1,6))))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
m=1 && 显示字段名下面的一行表格线
col1=1
Do While m<=n1
If m=1
@r1+2,col1 Say "├"+Replicate("─",b(m))
Else
If m=n1
@r1+2,col1 Say "┼"+Replicate("─",b(m))+"┤"
Else
@r1+2,col1 Say "┼"+Replicate("─",b(m))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
row1=r1+3
Do While .Not. Eof() && 每页显示20个记录
m=1 && 显示各记录的值
col1=1
Do While m<=n1
Do Case
Case Type(a(m))="C"
If m=1
@row1,col1 Say "│"+&a(m)
Else
If m=n1
@row1,col1 Say "│"+Alltrim(&a(m))+Replicate(" ",(b(m)-Len(Alltrim(&a(m)))))+"│"
Else
@row1,col1 Say "│"+&a(m)
Endif
Endif
Case Type(a(m))="N"
If m=1
@row1,col1 Say "│"+Str(&a(m))
Else
If m=n1
@row1,col1 Say "│"+Alltrim(Str(&a(m)))+Replicate(" ",(b(m)-Len(Alltrim(Str(&a(m))))))+"│"
Else
@row1,col1 Say "│"+Alltrim(Str(&a(m)))
Endif
ENDIF
Case Type(a(m))="D"
If m=1
@row1,col1 Say "│"+Dtoc(&a(m))
Else
If m=n1
@row1,col1 Say "│"+Alltrim(Dtoc(&a(m)))+Replicate(" ",(b(m)-Len(Alltrim(dtoc(&a(m))))))+"│"
Else
@row1,col1 Say "│"+Alltrim(dtoc(&a(m)))
Endif
ENDIF
Case Type(a(m))="L"
If m=1
@row1,col1 Say "│"+IIF(&a(m),".T.",".F.")
Else
If m=n1
@row1,col1 Say "│"+IIF(&a(m),".T.",".F.")+Replicate("",(b(m)-Len(Alltrim(&a(m)))))+"│"
Else
@row1,col1 Say "│"+IIF(&a(m),".T.",".F.")
Endif
ENDIF
Case Type(a(m))="G"
If m=1
@row1,col1 Say "│"+"gen"
Else
If m=n1
@row1,col1 Say "│"+Alltrim(&a(m))+Replicate(" ",(b(m)-Len(Alltrim(&a(m)))))+"│"
Else
@row1,col1 Say "│"+"gen"
Endif
ENDIF
Case Type(a(m))="M"
If m=1
@row1,col1 Say "│"+"memo"
Else
If m=n1
@row1,col1 Say "│"+"memo"+Replicate("",(b(m)-Len(Alltrim(&a(m)))))+SPACE(2)+"│"
else
@row1,col1 Say "│"+"memo"
Endif
Endif
ENDCASE
col1=col1+b(m)
m=m+1
Enddo
Skip
If Eof() && 显示数据库结束的最后一行
m=1
col1=1
Do While m<=n1
If m=1
@row1+1,col1 Say "└"+Replicate("─",b(m))
Else
If m=n1
@row1+1,col1 Say "┴"+Replicate("─",b(m))+"┘"
Else
@row1+1,col1 Say "┴"+Replicate("─",b(m))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
hh1=.F.
Exit
Else
If r1=20
m=1
col1=1
Do While m<=n1
If m=1
@row1+1,col1 Say "└"+Replicate("─",b(m))
Else
If m=n1
@row1+1,col1 Say "┴"+Replicate("─",b(m))+"┘"
Else
@row1+1,col1 Say "┴"+Replicate("─",b(m))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
r1=1
Eject
Exit
Else
m=1 && 显示每个记录下面的一行表格线
col1=1
Do While m<=n1
If m=1
@row1+1,col1 Say "├"+Replicate("─",b(m))
Else
If m=n1
@row1+1,col1 Say "┼"+Replicate("─",b(m))+"┤"
Else
@row1+1,col1 Say "┼"+Replicate("─",b(m))
Endif
Endif
col1=col1+b(m)
m=m+1
Enddo
Endif
Endif
row1=row1+2
r1=r1+1
Enddo && 每页显示20个记录到此
Enddo
Set Print Off
Set Device To Screen
Set Talk On
Return