$PBExportHeader$f_dsr_quck_dwtoexecl_3.srf global type f_dsr_quck_dwtoexecl_3 from function_object end type forward prototypes global function integer f_dsr_quck_dwtoexecl (ref datawindow dw_1) global function integer f_dsr_quck_dwtoexecl_3 (ref datawindow ad_dw, string arg_filename) end prototypes global function integer f_dsr_quck_dwtoexecl (ref datawindow dw_1); Long ls_rtn Long i,j String ls_s,ls_temp,ls_modify Long ll_cnt datastore ds ds = Create datastore ds.DataObject = "dw_dw_to_execl" ds.SetTransObject(sqlca) //parent.openuserobject(ds,1467,816) //如果是数据窗口控件类型 //ds.InsertRow(0) // //ds.SetItem(1,'spt1','fucker' ) //ds.SetItem(1,'spt2',' 些小厂v' ) // // messagebox('',string(ds.rowcount())) s_dw2xls_dytitle rtn_s_dw2xls_dytitle rtn_s_dw2xls_dytitle = f_quk_allcol(dw_1,dw_1.DataObject ) ll_cnt = UpperBound(rtn_s_dw2xls_dytitle.title_name) FOR j = 1 To ll_cnt ls_temp = 'spt' + String(j) ds.Modify(ls_temp + '.width = ' + '600') ds.Modify(ls_temp +"_t.text = '" + rtn_s_dw2xls_dytitle.title_name[j] + "'") NEXT FOR j = ll_cnt + 1 To 100 //隐藏列 ls_modify = '' ls_temp = 'spt' + String(j) ls_modify = ls_modify + "destroy " + ls_temp+ '_t ~n ' + ls_temp + '.visible=0 ~n ' IF ls_modify <> '' THEN ds.Modify(ls_modify) NEXT //查入行 for i=1 to dw_1.rowcount() ds.InsertRow(0) next //复制值 String ls_Evaluate_str FOR j = 1 To ll_cnt // messagebox('',string(dw_1.describe( "Evaluate('" + 'aaa' + "',2)" ))) //计算列 // //messagebox('',string(dw_1.Describe ( "Evaluate('LookupDisplay(" + 'username' + ")',1)" ))) //非计算列 IF rtn_s_dw2xls_dytitle.col_type[j] <> 'comp' THEN //非计算列 ls_Evaluate_str = '' FOR i = 1 To dw_1.RowCount() ls_Evaluate_str = String(dw_1.Describe ( "Evaluate('LookupDisplay(" +rtn_s_dw2xls_dytitle.col_name[j]+ ")'," + String(i)+ ")" )) ds.SetItem(i,'spt' + string(j),ls_Evaluate_str ) NEXT ELSE //计算列 ls_Evaluate_str = '' FOR i = 1 To dw_1.RowCount() ls_Evaluate_str = string(dw_1.describe( "Evaluate('" +rtn_s_dw2xls_dytitle.col_name[j] + "',"+string(i) + ")" ) ) if ls_Evaluate_str='!' then exit ds.SetItem(i,'spt' + string(j),ls_Evaluate_str ) NEXT END IF NEXT ls_rtn = ds.SaveAsAscii('C:\Users\dufff\Desktop\aaa.xls') IF ls_rtn = 1 THEN MessageBox('','导出成功') END IF return ls_rtn end function global function integer f_dsr_quck_dwtoexecl_3 (ref datawindow ad_dw, string arg_filename);Long ls_rtn datastore ds ds = Create datastore ds.DataObject = ad_dw.DataObject ad_dw.ShareData(ds) //messagebox('',string(ds.rowcount())) Long i, j, li_pos String ls_obj, ls_text, ls_err, ls_sql datastore lds_saveas //导出数据窗 datastore lds_sort //获得根据 object.x 排序的 (band = detail and visible = 1) 的 column/compute Boolean lb_return //返回值 String ls_pbver //pb 版本信息 environment env //环境变量 String ls_objects,ls_modify GetEnvironment(env) ls_pbver = String(env.PBMajorRevision) ls_objects = ds.Describe("datawindow.objects") //按~t位置作判断开始循环 DO While (Pos(ls_objects,"~t") > 0) li_pos = Pos(ls_objects,"~t") ls_obj = Left(ls_objects,li_pos - 1) ls_objects = Right(ls_objects,Len(ls_objects) - li_pos) //(column or compute ) at detail and visible If (ds.Describe(ls_obj+".band") = "summary" Or& Pos(ds.Describe(ls_obj+".band"),'trailer') > 0 Or& ds.Describe(ls_obj+".band") = "footer" ) THEN ls_modify = "destroy " +ls_obj+ ' ~n ' +ls_obj + '.visible=0 ~n ' IF ls_modify <> '' THEN ds.Modify(ls_modify) END IF LOOP ls_rtn = ds.SaveAsAscii(arg_filename) IF ls_rtn = 1 THEN ls_rtn = 1 ELSE ls_rtn = 0 END IF //Long i,j //String ls_s,ls_temp,ls_modify // //Long ll_cnt //datastore ds //ds = Create datastore // //ds.DataObject = "dw_dw_to_execl" //ds.SetTransObject(sqlca) ////parent.openuserobject(ds,1467,816) //如果是数据窗口控件类型 // // // // //s_dw2xls_dytitle rtn_s_dw2xls_dytitle // //rtn_s_dw2xls_dytitle = f_quk_allcol(dw_1,dw_1.DataObject ) //ll_cnt = UpperBound(rtn_s_dw2xls_dytitle.title_name) // //FOR j = 1 To ll_cnt // // ls_temp = 'spt' + String(j) // ds.Modify(ls_temp + '.width = ' + '600') // ds.Modify(ls_temp +"_t.text = '" + rtn_s_dw2xls_dytitle.title_name[j] + "'") // // // // //NEXT // //FOR j = ll_cnt + 1 To 100 //隐藏列 // ls_modify = '' // ls_temp = 'spt' + String(j) // ls_modify = ls_modify + "destroy " + ls_temp+ '_t ~n ' + ls_temp + '.visible=0 ~n ' // IF ls_modify <> '' THEN ds.Modify(ls_modify) // // //NEXT // ////查入行 //FOR i = 1 To dw_1.RowCount() // ds.InsertRow(0) //NEXT // // // ////复制值 //String ls_Evaluate_str //Open(w_sys_wait_jdt) //初始化进度条 //w_sys_wait_jdt.Show() //w_sys_wait_jdt.wf_accepttol(ll_cnt) //FOR j = 1 To ll_cnt // // IF rtn_s_dw2xls_dytitle.col_visible[j] = '0' THEN CONTINUE // w_sys_wait_jdt.st_msg.Text = rtn_s_dw2xls_dytitle.title_name[j] + " 正在导出execl..." //进度信息 // // messagebox('',string(dw_1.describe( "Evaluate('" + 'aaa' + "',2)" ))) //计算列 // // // //messagebox('',string(dw_1.Describe ( "Evaluate('LookupDisplay(" + 'username' + ")',1)" ))) //非计算列 // // // IF rtn_s_dw2xls_dytitle.col_type[j] <> 'comp' THEN //非计算列 // ls_Evaluate_str = '' // FOR i = 1 To dw_1.RowCount() // ls_Evaluate_str = String(dw_1.Describe ( "Evaluate('LookupDisplay(" +rtn_s_dw2xls_dytitle.col_name[j]+ ")'," + String(i)+ ")" )) // ds.SetItem(i,'spt' + String(j),ls_Evaluate_str ) // NEXT // // // ELSE //计算列 // ls_Evaluate_str = '' // FOR i = 1 To dw_1.RowCount() // // ls_Evaluate_str = String(dw_1.Describe( "Evaluate('" +rtn_s_dw2xls_dytitle.col_name[j] + "',"+String(i) + ")" ) ) // // IF ls_Evaluate_str = '!' THEN EXIT // ds.SetItem(i,'spt' + String(j),ls_Evaluate_str ) // NEXT // END IF // // // w_sys_wait_jdt.wf_inc(j) //进度 //NEXT // // // // // // // // // // // // // ls_rtn = ds.SaveAsAscii(arg_filename) // //Close(w_sys_wait_jdt) IF ls_rtn = 1 THEN ls_rtn = 1 ELSE ls_rtn = 0 END IF RETURN ls_rtn end function