PB从EXCEL中导入数据到数据窗口的程序(1)

//***************************************************************//
// 函数名称: GF_EXCEL_TO_DATAWINDOW                                                             
// 函数功能: EXCEL文件导入DATAWINDOW                                                            
// 参数类型: DWTAWINDOW                                                             
// 参数名称: DW                                                             
// RETURN  : 1 SUCCEED   -1 ERROR                                                             
// DATE    : 2004 3.1                                                                           
//***************************************************************//

string str_savename,named,s_grxh
int  excelok,li_net
long li_count,i


oleobject excelserver
excelserver=create oleobject
excelok=excelserver.connecttonewobject("excel.application")

//检查返回值,以确保已成功地连接到了Excel
if excelok <> 0 then
messagebox("信息提示","连接EXCEL失败,请检查计算机中是否安装了EXCEL!")
return -1
end if
li_net = GetFileOpenName("选择文件", str_savename,named,"xls","Excel文件(*.xls),*.xls")
if li_net > 0 then
if str_savename = "" then  return -1
dw.settransobject(sqlca)
dw.reset()
excelserver.workbooks.open(str_savename)
excelserver.activesheet.cells.copy
li_count = dw.importclipboard(2)  //导入数据
clipboard("")

excelserver.quit()
excelserver.disconnectobject()
destroy excelserver
return 1
else
messagebox('信息提示','没有指定导入文件!')
return -1
end if

你可能感兴趣的:(报表,PowerBuilder)