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

fromv 2004-08-04 11:41:47
需要将dbf格式的表转换为excel表,可是我不会vfp.很急的,大家帮忙啊
...全文
1858 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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
加载更多回复(8)

2,726

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧