資源描述:
《將PB數(shù)據(jù)窗口數(shù)據(jù)導(dǎo)出到EXCEL模版.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、將PB數(shù)據(jù)窗品導(dǎo)出到EXCEL模版一、建立通信OLEObjectExcelServerIntegerli_excelOK,li_rcStringls_path,ls_file,ls_modelExcelServer=CREATEOLEObjectli_ExcelOK=ExcelServer.ConnectToNewObject("excel.application")二、輸入新文件名li_rc=GetFileSaveName("輸入新的文件名",&ls_path,ls_file,"XLS",&"XLSFiles(*.XLS),*.
2、XLS","C:MyDocuments",&32770)三、判斷文件是否存在IfFileExists(ls_path)ThenFileDelete(ls_path)ENDIF四、檢查給定的文件路徑是否可以寫入li_rc=FileOpen(ls_path,StreamMode!,Write!,LockWrite!,Replace!)FileClose(li_rc)filedelete(ls_path)五、獲到模版文件ifFileExists(ls_model)thenli_rc=FileCopy(ls_model,ls_path,
3、true)ifli_rc=1thenExcelServer.Workbooks.Open(ls_path)elseExcelServer.workbooks.addExcelServer.Workbooks(1).SaveAs(ls_path)ExcelServer.Workbooks.Open(ls_path)endifendif六、寫入數(shù)據(jù)窗品數(shù)據(jù)ExcelServer.application.Sheets(“sheet1”).SelectExcelServer.ActiveSheet.Cells(2,1).value='制單
4、編號(hào)'七、保存EXCEL數(shù)據(jù)//關(guān)閉警告消息對(duì)話框,防止退出Excel時(shí)提示ExcelServer.Application.DisplayAlerts=False//保存數(shù)據(jù)ExcelServer.Application.SaveWorkspace()iff_messagebox('','已成功導(dǎo)出到EXCEL,是否要打開該文件:',2)=1thenExcelServer.Application.Visible=trueelseExcelServer.Application.Visible=falseExcelServer.qui
5、t()endifExcelServer.disconnectobject()destroyexcelserver