sql表中有243列,求导出dbf格式文件的步骤(卫统N042表)

sql表中有243列,求导出dbf格式文件的方法(卫统N042表)
用pb把datawindow保存为dbf(3,4,5)格式时列数少时(网上说128列),可以正常保存,但这个表列数太多了,保存时出错。
先保存成access2003格式,再从access2003中导出为dbf也是出错。
保存成excel,再另存为dbf保存时不出错,但在卫统N042表上报引入dbf时,会出错!
excel直接改扩展名为dbf也不行。。。
还有什么办法?谁做过新的卫统N042表的接口数据?

------解决方案--------------------
本帖最后由 lzp_lrp 于 2013-04-27 10:02:48 编辑
还有一个办法,保存一个10个的数据窗口为dbf文件,然后研究一下dbf文件的格式,然后使用fileopen、filewrite来自己生成一个dbf文件,我以后做财务接口时这么做过,生成dbf文件格式比较简单,前面的内容是固定的(好象只需要改个列数),你研究一下


以下是我做生成dbf文件的参考例子

(最后一段放在这里了,因为只允许连接回复三次)


for ll_row = 1 to ll_cnt
ls_blob = ''
for ll_item_row = 1 to ll_item_cnt
ls_col_nam = idw_item.getitemstring(ll_item_row, "column_nam")
ll_item_len = idw_item.getitemnumber(ll_item_row, "item_num")
if idw_data.describe(ls_col_nam + ".visible") = '!' then
ls_data = space(ll_item_len)
else
choose case idw_item.getitemstring(ll_item_row, "item_typ")
case 'string'
ls_data = idw_data.getitemstring(ll_row, ls_col_nam)
if len(ls_data) > 0 then
//
else
ls_data = ''
end if
ls_data = left(ls_data + space(ll_item_len), ll_item_len)
case 'number'
ls_data = string(idw_data.getitemnumber(ll_row, ls_col_nam), '##########.00000')
if len(ls_data) > 0 then
//
else
ls_data = ''
end if
ls_data = right(space(ll_item_len) + ls_data, ll_item_len)
case 'date'
ls_data = string(idw_data.getitemdatetime(ll_row, ls_col_nam), 'YYYYMMDD')
if len(ls_data) > 0 then
//
else
ls_data = ''
end if
ls_data = left(ls_data + space(ll_item_len), ll_item_len)
end choose
end if

ls_blob += ls_data
next

ls_blob = left(ls_blob, len(ls_blob) - 1)
//ls_blob += space(59) //space(80) + space(80) + space(20)
if ll_row = ll_cnt then
ls_blob += '~h31~h1A'
else
ls_blob += '~h31~h20'
end if

FileWrite(ll_handle, ls_blob)
next
FileClose(ll_handle)

return 1

------解决方案--------------------

nvo_commdlg_excel Dialogs
string ls_title =  "文件另存为"
string ls_filter = "DBF文件(*.dbf)~t*.dbf~tALL文件(*.*)~t*.*"
string ls_initialdir = "C:\My Documents"
string ls_filename //保存的文件名,包括路径及扩展名;
string ls_extendname //文件扩展名;如".psr"
integer li_ret
long li_type

Dialogs.hWndParent = Handle(this)
Dialogs.Title = ls_title
Dialogs.Filter = ls_filter
Dialogs.FilterIndex =  1