String ls_kjname = '' //控件名
String ls_colname = '' //字段名
String ls_kjnametemp = '' //临时存放string型日期值
String ls_docname = '' //文件完整路径
String ls_named = '' //文件名
String ls_sname_e = '' //标题英文名
String ls_sname_c = '' //标题中文名
String ls_value = '' //显示数据
String ls_visible = '' //可见属性
String ls_zcxx = '' //转存时信息
String ls_arname_c[] //数组中文名标题
Integer li_value = 0 //GetFilesaveName()返回值
Long ll_j = 0 //循环变量ll_j
Long ll_step = 0 //循环变量ll_step
Long ll_rowCount = 0 //显示数据的总行数
Long li_rowcount = 0 //记录总行数
Integer li_no = 0 //退出标记
Integer li_colcount = 0 //显示数据的总列数
Integer li_colNum = 0 //列数
Integer i = 0 //循环变量i
datastore lds_excel //临时DS
li_rowcount = dw_data.RowCount( )
If li_rowcount <= 0 Then
f_fmwshowmsg("M004I")
RETURN
Else
Do Until li_no = 1
//数据转存临时
DS lds_excel = Create datastore
lds_excel.DataObject = 'dw_sbnl_no'
lds_excel.SetTransObject(sqlca)
lds_excel.Reset()
//样品编号
DataWindow li_colcount = Integer(dw_data.object.datawindow.column.count)
ll_rowCount = dw_data.rowcount()
for ll_step = 1 to (ll_rowCount+1)
//临时DS增加要导出记录行数+1
lds_excel.insertrow(0)
next
for ll_step = 1 to li_colcount
ls_sname_e=Trim(dw_data.Describe("#"+string(ll_step)+'.name'))
//获得第i个字段的名称
ls_sname_c=Trim(dw_data.Describe(ls_sname_e+'_t.text'))
ls_visible=Trim(dw_data.Describe("#"+string(ll_step)+'.visible'))
if ls_sname_c = '!' or Trim(ls_sname_c) = '' or ls_visible = '0' then continue
li_colNum ++
lds_excel.setitem(1,"col"+string(li_colNum),ls_sname_c)
//加标题
for ll_j = 1 to ll_rowCount
//给临时DS第ll_j行第ll_step列赋值
if dw_data.describe(ls_sname_e + '.Type') = 'column' then
ls_value = dw_data.describe("Evaluate('LookupDisplay(" + ls_sname_e + ")',"+string(ll_j)+")")
end if
lds_excel.setitem(ll_j+1,"col"+string(li_colNum),ls_value)
next
next
li_value = GetFilesaveName("Save File",ls_docname, ls_named, "CSV", & + "CSV Files (*.XLS),*.XLS")
If li_value = 1 Then
If FileExists(ls_docname) Then
li_no = MessageBox("提示",ls_docname + "已经存在!是否覆盖?",Question!,YesNo!)
If li_no = 1 Then
lds_excel.SaveAs(ls_docname,EXCEL!,FALSE)
destroy lds_excel
Else
li_no = 1
End If
Else
lds_excel.SaveAs(ls_docname,EXCEL!,FALSE)
destroy lds_excel
li_no = 1
End If
Else
li_no = 1
End If
Loop
If li_value = -1 Then
f_fmwshowmsg("M022I")
RETURN
End If
End If