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