*THISFORM.INIT()
*初始化设置
*
*新建一个表单后保存。
*在该表单里,添加
*2个标签LABEL1和LABEL2;
*2个文本框TEXT1和TEXT2;
*4个命令按钮COMMAND1-COMMAND4;
*1个表格GRID1
*
SET TALK OFF
SET SAFETY OFF
PUBLIC LOK
LOK=.F.
*设置FORM1的属性
THISFORM.WIDTH=480
THISFORM.HEIGHT=317
THISFORM.MINWIDTH=480
THISFORM.MINHEIGHT=317
THISFORM.CAPTION="由DBF导出和导入XLS (C)Copyright 2006-2006 By Tiger5392"
THISFORM.CONTROLBOX=.F.
THISFORM.AUTOCENTER=.T.
*设置LABEL1的属性
THISFORM.LABEL1.AUTOSIZE=.T.
THISFORM.LABEL1.CAPTION=[DBF文件]
THISFORM.LABEL1.LEFT=0
THISFORM.LABEL1.TOP=3
*设置LABEL2的属性
THISFORM.LABEL2.AUTOSIZE=.T.
THISFORM.LABEL2.CAPTION=[XLS文件]
THISFORM.LABEL2.LEFT=0
THISFORM.LABEL2.TOP=26
*设置TEXT1的属性
THISFORM.TEXT1.LEFT=THISFORM.LABEL1.LEFT+THISFORM.LABEL1.WIDTH
THISFORM.TEXT1.TOP=2
THISFORM.TEXT1.READONLY=.T.
THISFORM.TEXT1.WIDTH=THISFORM.WIDTH-THISFORM.LABEL1.WIDTH-THISFORM.COMMAND1.WIDTH
*设置TEXT2的属性
THISFORM.TEXT2.LEFT=THISFORM.LABEL2.LEFT+THISFORM.LABEL2.WIDTH
THISFORM.TEXT2.TOP=24
THISFORM.TEXT2.WIDTH=THISFORM.TEXT1.WIDTH
*设置COMMAND1的属性
THISFORM.COMMAND1.AUTOSIZE=.T.
THISFORM.COMMAND1.CAPTION=[...]
THISFORM.COMMAND1.TOP=0
THISFORM.COMMAND1.LEFT=THISFORM.TEXT1.LEFT+THISFORM.TEXT1.WIDTH
*设置COMMAND2的属性
THISFORM.COMMAND2.AUTOSIZE=.T.
THISFORM.COMMAND2.CAPTION=[导出(DBF->X\<LS)]
THISFORM.COMMAND2.TOP=THISFORM.HEIGHT-THISFORM.COMMAND2.HEIGHT-2
THISFORM.COMMAND2.ENABLED=.F.
*设置COMMAND3的属性
THISFORM.COMMAND3.AUTOSIZE=.T.
THISFORM.COMMAND3.CAPTION=[导入(D\<BF<-XLS)]
THISFORM.COMMAND3.TOP=THISFORM.COMMAND2.TOP
THISFORM.COMMAND3.ENABLED=.F.
*设置COMMAND4的属性
THISFORM.COMMAND4.AUTOSIZE=.T.
THISFORM.COMMAND4.CAPTION=[结束(\<X)]
THISFORM.COMMAND4.TOP=THISFORM.COMMAND2.TOP
*单独设置COMMAND2-COMMAND4的LEFT属性
THISFORM.COMMAND2.LEFT=(THISFORM.WIDTH-THISFORM.COMMAND2.WIDTH-THISFORM.COMMAND3.WIDTH-THISFORM.COMMAND4.WIDTH)/2
THISFORM.COMMAND3.LEFT=THISFORM.COMMAND2.LEFT+THISFORM.COMMAND2.WIDTH
THISFORM.COMMAND4.LEFT=THISFORM.COMMAND3.LEFT+THISFORM.COMMAND3.WIDTH
*设置GRID1的属性
THISFORM.GRID1.TOP=THISFORM.TEXT2.TOP+THISFORM.TEXT2.HEIGHT+2
THISFORM.GRID1.LEFT=0
THISFORM.GRID1.WIDTH=THISFORM.WIDTH
THISFORM.GRID1.HEIGHT=THISFORM.HEIGHT-THISFORM.GRID1.TOP-THISFORM.COMMAND2.HEIGHT-2
THISFORM.GRID1.VISIBLE=.F.
*特别注意,任何控件的其他任何属性都取其默认值
*THISFORM.RESIZE()
*改变表单的宽度和高度后重新布局有关控件
*
*当表单的宽度和长度改变的时候,允许
*TEXT1,TEXT2,GRID1的宽度(.WIDTH)改变,
*GRID1的高度(.HEIGHT)改变,
*COMMAND1-COMMAND4的左边距(.LEFT)改变,
*COMMAND2-COMMAND4的顶边距(.TOP)改变
*其他任何属性都不变
*
THISFORM.TEXT1.WIDTH=THISFORM.WIDTH-THISFORM.LABEL1.WIDTH-THISFORM.COMMAND1.WIDTH
THISFORM.TEXT2.WIDTH=THISFORM.TEXT1.WIDTH
THISFORM.GRID1.WIDTH=THISFORM.WIDTH
THISFORM.GRID1.HEIGHT=THISFORM.HEIGHT-THISFORM.GRID1.TOP-THISFORM.COMMAND2.HEIGHT-2
THISFORM.COMMAND1.LEFT=THISFORM.TEXT1.LEFT+THISFORM.TEXT1.WIDTH
THISFORM.COMMAND2.LEFT=(THISFORM.WIDTH-THISFORM.COMMAND2.WIDTH-THISFORM.COMMAND3.WIDTH-THISFORM.COMMAND4.WIDTH)/2
THISFORM.COMMAND3.LEFT=THISFORM.COMMAND2.LEFT+THISFORM.COMMAND2.WIDTH
THISFORM.COMMAND4.LEFT=THISFORM.COMMAND3.LEFT+THISFORM.COMMAND3.WIDTH
THISFORM.COMMAND2.TOP=THISFORM.GRID1.TOP+THISFORM.GRID1.HEIGHT+2
THISFORM.COMMAND3.TOP=THISFORM.COMMAND2.TOP
THISFORM.COMMAND4.TOP=THISFORM.COMMAND2.TOP
*THISFORM.COMMAND1.CLICK()
*本命令是选取DBF文件
cFileName=GETFILE("DBF")
LOK=.F.
IF EMPTY(cFileName)
THISFORM.GRID1.VISIBLE=.F.
THISFORM.TEXT1.VALUE=""
THISFORM.TEXT2.VALUE=""
THISFORM.COMMAND2.ENABLED=.F.
THISFORM.COMMAND3.ENABLED=.F.
ELSE
THISFORM.TEXT1.VALUE=cFileName
THISFORM.TEXT2.VALUE=LEFT(cFileName,LEN(cFileName)-3)+"XLS"
CLOSE ALL
USE (cFileName)
THISFORM.GRID1.RECORDSOURCETYPE=1
THI