VFP中表如何导出为csv文件
VFP数据表记录为1217110,想另存为EXCEL文档,用copyto命令只能导出15534条记录,如何实现?谢谢!要求能直接存储为csv文件就可以了...
VFP数据表记录为1217110,想另存为EXCEL文档,用copy to 命令只能导出15534条记录,如何实现?谢谢!
要求能直接存储为csv文件就可以了 展开
要求能直接存储为csv文件就可以了 展开
展开全部
下面语句可以将DBF表中字段保存到EXCEL中,记录长度不受限制。
lcFileName="C:\ABC.XLS"
LOCAL lOldSetOpt,mChanNum &&下面语句判断EXCEL或要保存的EXCEL文件是否已经打开
lOldSetOpt = DDESetOption("SAFETY")
= DDESetOption("SAFETY",.F.)
**mChanNum = DDEInitiate('Excel','SYSTEM') &&EXCEL是否已经打开
mChanNum = DDEInitiate('Excel','&lcFileName') &&lcFileName某XLS文件名,如:D:\123.XLS
IF mChanNum <> -1
= messagebox('文件【'+lcFileName+'】已经打开,请先将其关闭!',64,'系统提示!')
= DDETerminate(mChanNum)
= DDESetOption("SAFETY",lOldSetOpt)
RETURN
ENDIF
IF FILE(lcFileName)
DELETE FILE &lcFileName
ENDIF
eole=CREATEOBJECT("Excel.application")
eole.Workbooks.add
eole.Worksheets("sheet1").Activate
eole.cells(1,1)="书号"
eole.cells(1,2)="自编号"
eole.cells(1,3)="书名"
eole.cells(1,4)="作者"
eole.cells(1,5)="出版社"
eole.cells(1,6)="定价"
eole.cells(1,7)="折扣"
eole.cells(1,8)="出版年限"
Sele BookInfo
SCAN
i=RECNO()
eole.cells(i+1,1)="'"+ALLTRIM(isbn)
eole.cells(i+1,2)=ALLTRIM(selfcode)
eole.cells(i+1,3)=ALLTRIM(booktitle)
eole.cells(i+1,4)=ALLTRIM(author)
eole.cells(i+1,5)=ALLTRIM(pubname)
eole.cells(i+1,6)=price
eole.cells(i+1,7)=Discount
eole.cells(i+1,8)=IIF(ISNULL(PubDate),"",TTOD(Pubdate))
ENDSCAN
eole.ActiveWorkbook.SaveAs(lcFileName)
eole.Workbooks.close
eole.quit
lcFileName="C:\ABC.XLS"
LOCAL lOldSetOpt,mChanNum &&下面语句判断EXCEL或要保存的EXCEL文件是否已经打开
lOldSetOpt = DDESetOption("SAFETY")
= DDESetOption("SAFETY",.F.)
**mChanNum = DDEInitiate('Excel','SYSTEM') &&EXCEL是否已经打开
mChanNum = DDEInitiate('Excel','&lcFileName') &&lcFileName某XLS文件名,如:D:\123.XLS
IF mChanNum <> -1
= messagebox('文件【'+lcFileName+'】已经打开,请先将其关闭!',64,'系统提示!')
= DDETerminate(mChanNum)
= DDESetOption("SAFETY",lOldSetOpt)
RETURN
ENDIF
IF FILE(lcFileName)
DELETE FILE &lcFileName
ENDIF
eole=CREATEOBJECT("Excel.application")
eole.Workbooks.add
eole.Worksheets("sheet1").Activate
eole.cells(1,1)="书号"
eole.cells(1,2)="自编号"
eole.cells(1,3)="书名"
eole.cells(1,4)="作者"
eole.cells(1,5)="出版社"
eole.cells(1,6)="定价"
eole.cells(1,7)="折扣"
eole.cells(1,8)="出版年限"
Sele BookInfo
SCAN
i=RECNO()
eole.cells(i+1,1)="'"+ALLTRIM(isbn)
eole.cells(i+1,2)=ALLTRIM(selfcode)
eole.cells(i+1,3)=ALLTRIM(booktitle)
eole.cells(i+1,4)=ALLTRIM(author)
eole.cells(i+1,5)=ALLTRIM(pubname)
eole.cells(i+1,6)=price
eole.cells(i+1,7)=Discount
eole.cells(i+1,8)=IIF(ISNULL(PubDate),"",TTOD(Pubdate))
ENDSCAN
eole.ActiveWorkbook.SaveAs(lcFileName)
eole.Workbooks.close
eole.quit
追问
谢谢朋友,用该方法作了,只能用于数目小于65000条记录的表,大于65000后就提示“无效的下标引用”,请问如何解决?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
将数据表分成几个临时表,每个临时表存放不超过15534条记录,然后转成excel,最后将各个excel表进行合并。
追问
谢谢朋友,可这个表有100多万条记录啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询