高手帮忙!求dbf转换到excel的程序

fromv 2004-08-04 11:41:47
需要将dbf格式的表转换为excel表,可是我不会vfp.很急的,大家帮忙啊
...全文
1831 点赞 收藏 28
写回复
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
st_2000 2004-08-20
这个问题已问过很多次了。找找贴子吧
回复
gosea 2004-08-19
在一个程序中加上定时器,定时执行处理程序不就得了
回复
fromv 2004-08-18
是要定时对dbf表进行转换。
回复
xclzteb 2004-08-13
给你讲得很清楚了这位朋友,我不能连续发三次以上的帖子,内容太长。若有需要请把邮件地址发到我的邮箱:RAHQ@SINA.COM
回复
xclzteb 2004-08-11
那是自然了,已经删除的数据可以在VFP中用Set delete语句来设置是否被访问。谁说的不能脱离VFP运行,做好后生成安装程序就可以了。楼上的几种方法都可以的。
回复
noproblem12 2004-08-11
呵呵,直接把后缀改成xls就行了,
回复
xclzteb 2004-08-11

*!* The following code determines the selected range of the print area for *!*
*!* the derived Excel file. This is based on the number of fields in the *!*
*!* source table (columns) and the number of records in the source table *!*
*!* (rows). A range of three rows is added to the number of records. This *!*
*!* allows for the following: *!*
*!* One row is added by the COPY TO process to hold the names of the fields. *!*
*!* One row is inserted as a spacer between the field names and the first *!*
*!* row of data. *!*
*!* One row is added to the bottom to contain a SUM function for numeric, *!*
*!* integer, and/or currency data. *!*
lcTotalRangeExpr = ;
["A1:] + ColumnLetter(FCOUNT()) + ALLTRIM(STR(RECCOUNT() + 3)) + ["]
lcTotalPrintArea = ;
["$A$1:$] + ColumnLetter(FCOUNT()) + [$]+ALLTRIM(STR(RECCOUNT() + 3)) + ["]

*!* The following code will erase any previously created temporary excel *!*
*!* file created by this program *!*
IF FILE(HOME() + "VFP_to_Excel.xls")
ERASE HOME() + "VFP_to_Excel.xls"
endif

*!* The following code creates the temporary Excel file that will be used *!*
*!* for the derived Excel file *!*
COPY TO HOME() + "VFP_to_Excel" TYPE XL5

*!* The following code commences the OLE Automation process. *!*
oExcelObject = CREATEOBJECT('Excel.Application')

*!* The following code opens the "VFP_to_Excel" file that was created by the *!*
*!* "COPY TO" command *!*
oExcelWorkbook = ;
oExcelObject.Application.Workbooks.Open(HOME() + "VFP_to_Excel")

*!* The following code activates the Worksheet which contains the "COPY TO" *!*
*!* data *!*
oActiveExcelSheet = oExcelWorkbook.Worksheets("VFP_to_Excel").Activate
*!*oExcelWorkbook.Worksheets.add
*!*oExcelWorkbook.Worksheets.Item(1).name="rahq1"
&&oExcelWorkbook.Worksheets("VFP_to_Excel").move
oActiveExcelSheet = oExcelWorkbook.Worksheets("VFP_to_Excel").Activate
*!* The following code establishes an Object Reference to the "VFP_to_Excel" *!*
*!* worksheet *!*
oExcelSheet = oExcelWorkbook.Worksheets("VFP_to_Excel")
oExcelSheet.name="示例"
回复
xclzteb 2004-08-11
PARAMETER lnPaperOrientation

*!* 1 = letter size paper, portrait orientation (1,1) *!*
*!* 2 = letter size paper, landscape orientation (1,2) *!*
*!* 3 = legal size paper, portrait orientation (5,1) *!*
*!* 4 = legal size paper, landscape orientation (5,2) *!*

*!* The following line of code sets a default lnPaperOrientation value of 1 *!*
*!* where no parameter is passed

lnPaperOrientation = ;
IIF(TYPE("lnPaperOrientation") = "L", 1, lnPaperOrientation)

*!* The following code sets the paper size and orientation variables based *!*
*!* on the lnPaperOrientation value *!*
DO CASE

CASE lnPaperOrientation = 2
lnPaperSize = 1
lnPrintOrientation = 2

CASE lnPaperOrientation = 3
lnPaperSize = 5
lnPrintOrientation = 1

CASE lnPaperOrientation = 4
lnPaperSize = 5
lnPrintOrientation = 2

OTHERWISE

lnPaperSize = 1
lnPrintOrientation = 1

ENDCASE

*!* The following code determines whether or not there is a table open in *!*
*!* the currently selected work area. *!*
lcTableAlias = ALIAS()
IF EMPTY(lcTableAlias)
=MESSAGEBOX("A table must be open in the currently selected work area" + ;
CHR(13) + "in order for this program to work.")
aa=GETFILE("dbf")
IF !EMPTY(aa) AND FILE(aa)
SELECT 0
USE (aa)
else
RETURN && If no table is open, then return *!*
endif
ENDIF

*!* The following code determines the derived Excel file name and location. *!*
lcTablePath = LEFT(DBF(), RAT("\", DBF()))
lcExcelFile = lcTablePath + lcTableAlias + ".xls"
IF FILE(lcExcelFile) && If a file by the derived name already *!*
*!* exists in the derived location *!*
lcMessageText = "An Excel file by the name of " + lcTableAlias + ;
".xls" + CHR(13) + "already exists at location:" + CHR(13) + ;
lcTablePath + CHR(13) + ;
"Do you want to delete it now and replace it?"
lnDialogType = 4 + 32 + 256
lnFirstWarning = MESSAGEBOX(lcMessageText, lnDialogType)
IF lnFirstWarning = 6 && User responds with a "Yes" *!*
lcMessageText = "This will delete the exist file:" + CHR(13) + ;
lcExcelFile + CHR(13) + ;
"Are you certain?"
lnDialogType = 4 + 48 + 256
lnSecondWarning = MESSAGEBOX(lcMessageText, lnDialogType)
IF lnSecondWarning = 6 && User responds with a "Yes" *!*
ERASE (lcExcelFile) && Erase the existing file *!*
ELSE
RETURN
ENDIF
ELSE
RETURN
ENDIF
ENDIF
回复
fromv 2004-08-10
VFP的DBF文件在转移到msSQL时数据转换不全,老是把做了删除标记的数据漏掉了。用其他的工具都出现这个问题。只好用VFP把他转换为xls之后来处理。
这个问题没有人遇到吗?
回复
十月鹰飞 2004-08-10
楼主是要这个程序定时对表进行转换?
回复
Keown 2004-08-09
sorry,不是资源管理器是企业管理器
回复
Keown 2004-08-09
安装SQL-Server2000后,打开资源管理器--数据转换服务--本地包,右键新建包,新建源连接DBF资料库,建立目的连接xls,然后加入处理动作,具体可以参考帮助文件,待所有工作完成,可以测试封包文件的执行情况,修改达到目的为止
保存封包文件为bas文件,在vb中新建一个project,加入该bas文件,编译成exe文件后,可以使用计划任务排程自动执行
这样应该可以了,因为DTS支援ODBC-ODBC脱离SQL-server运行环境的数据转换
可以试一下
回复
Keown 2004-08-06
使用SQL-Server中的DTS转换,来源为.dbf文件,目的为.xls文件
回复
流星尔 2004-08-06
不需要安装VFP
回复
流星尔 2004-08-06
脱离VFP环境,你只要把那些库放到SYSTEM32下(2000),system(win98)下,就可以运行程序了。
回复
流星尔 2004-08-06
自动转换,怎么实现,
回复
qufusongyu 2004-08-06
如果不懂vfp的话,建议使用楼上的。
JohnShen(因果网) ( )
将表aa.dbf转成c:\aa.xls:
Use aa
COPY TO c:\aa.xls TYPE XL5

回复
fromv 2004-08-06
非常感谢大家的关注。不过还是没有达到要求。难道我说的不清楚吗?
to Keown(坤):
VFP的DBF文件在转移到msSQL时数据转换不全,老是把做了标记的数据漏掉了。用其他的工具都出现这个问题。只好用VFP把他转换为xls之后来处理。这个dbf文件每天都会产生,所以想用程序来进行自动转换。不能每天都手动操作吧。
不要再告诉我用copy 语句,那个必须在vfp环境里执行的;不要再告诉用Excel来转换。我希望的是一个程序,一个可以在windows或dos下执行的程序。
回复
zhaoshaom 2004-08-06
两种方法,一种是打开一个表,用VFP另存为网页的形式,一个是采用先: USE 表.DBF
COPY TO C:\文件名 type xl5,就可以了.
回复
Keown 2004-08-06
另:工程中需引用DTS Package Objects
回复
发动态
发帖子
VFP
创建于2007-09-28

2455

社区成员

VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
申请成为版主
社区公告
暂无公告