首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > VFP >

,怎么将表中的某一字段查询并导出到excel

2012-08-09 
请教高手,如何将表中的某一字段查询并导出到excel如:SET DEFAULT TO D:\DATA1SELECT *,SPACE(10) AS C_FIE

请教高手,如何将表中的某一字段查询并导出到excel
如:
SET DEFAULT TO D:\DATA1

SELECT *,SPACE(10) AS C_FIELD FROM ab070000 INTO TABLE ab070000
replace all c_field with "ab070000"

for i=1 to 199
  if file("ab070"+padl(i,3,"0")+".dbf") && 文件存在,就追加到ab070000中
  append from "ab070"+padl(i,3,"0")
  replace all c_field with "ab070"+padl(i,3,"0") for empty(c_field)
  endif
endfor
browse for gze>2000
CLOSE TABLES

将gze>2000的记录都导出到excel

[解决办法]
SET DEFAULT TO D:\DATA1

SELECT *,SPACE(10) AS C_FIELD FROM ab070000 INTO TABLE ab070000
replace all c_field with "ab070000"

for i=1 to 199
if file("ab070"+padl(i,3,"0")+".dbf") && 文件存在,就追加到ab070000中
append from "ab070"+padl(i,3,"0")
replace all c_field with "ab070"+padl(i,3,"0") for empty(c_field)
endif
endfor
browse for gze>2000
copy to ab070000.xls xl5 for gze>2000
CLOSE TABLES

[解决办法]
Set Default To D:\DATA1
Select *,Space(20) As 表名 Into Table 总表 From ab070000
Select 总表
For lnI=0 To 199
lcDbfName='ab0'+Transform(70000+lnI)+'.dbf'
If File(lcDbfName)
Append From (lcDbfName)
Replace All 表名 With lcDbfName For Empty(表名)
Endif
Endfor
Locate
Browse && 看一下总表数据

*Select * From 总表 Where gze>2000 && 这是 gze>2000 的数据
Select * Into Table gze2000 From 总表 Where gze>2000
Select gze2000
Copy To Excel名称.Xls Type Xl5

热点排行