EXCEL、dbf、word文件互转.rar
VFP环境下文件转换原码
源代码在线查看: 将vfp的dbf导出到word.txt
将VFP的DBF导出到WORD
以下这段代码就能直接把一个DBF转为DOC
什么参数都不用加,在要在当前工作区打开表就行了
************************************
IF EMPTY(ALIAS())
MessageBox( "当前工作区没有打开工作表!",48,"不能生成表格")
ENDIF
WAIT "正在访问 Word 软件……" WINDOW NOWAIT
WordApp=CREATEOBJECT("Word.application") &&访问WORD
If Type("WordApp")#"O"
WAIT CLEAR
MessageBox( "访问Word失败!请检查你的系统是否正确安装 Word 软件!",48,"没有安装Word")
RETURN
ENDIF
WAIT "正在生成表格……" WINDOW NOWAIT
WordApp.Visible =.f.
WordApp.Caption ='yafox.com'
WordApp.Documents.Add
WordApp.Documents(1).Range.Text=ALIAS()
WordApp.Documents(1).Range.Font.Size=15
WordApp.Documents(1).Range.Font.Name="黑体"
WordApp.Documents(1).Range.Paragraphs.Alignment= 1
WordAppRang=WordApp.Documents(1).Range(LENC(WordApp.Documents(1).Range.Text)-1,LENC(WordApp.Documents(1).Range.Text)-1)
WordTable=WordApp.Documents(1).Tables.Add(WordAppRang,RECCOUNT()+1,FCOUNT())
WordTable.Range.Paragraphs.Alignment= 0
WordTable.Range.Font.Name="宋体"
WordTable.Range.Font.Size=11
WordTable.Borders.Enable=1
WordTable.Borders(1).LineWidth = 12
WordTable.Borders(2).LineWidth = 12
WordTable.Borders(3).LineWidth = 12
WordTable.Borders(4).LineWidth = 12
WordTable.Rows(1).Borders(3).LineWidth = 12
WordTable.Rows(1).Range.Font.Bold=.t.
WordTable.Rows(1).Cells.VerticalAlignment= 1
WordTable.Rows(1).Range.Paragraphs.Alignment = 1
WordTable.Rows(1).HeadingFormat=.t.
FOR i=1 TO FCOUNT()
WordTable.Cell(1,i).Range.Text=FIELD(i)
FOR i2=2 TO RECCOUNT()+1
GO i2-1
WordCellText=EVALUATE(FIELD(i))
DO CASE
CASE ISNULL(WordCellText)
WordCellText=""
CASE TYPE("WordCellText")="N"
CASE TYPE("WordCellText")="D"
WordCellText=DTOC(WordCellText)
CASE TYPE("WordCellText")="T"
WordCellText=TTOC(WordCellText)
CASE EMPTY(WordCellText)
WordCellText=""
OTHERWISE
* WordCellText=""
ENDCASE
WordTable.Cell(i2,i).Range.Text=WordCellText
NEXT
WordTable.Columns(i).AutoFit
NEXT
WordApp.Documents(1).SaveAs("C:\Xwy.doc")
WordApp.Quit
RELEASE WordApp
WAIT CLEAR
MessageBox( "生成WORD文件完毕,文件位置 C:\Xwy.doc !",64,"完毕")
RETURN