`
wms20070910
  • 浏览: 97438 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

数据导入(Lotus Notes)

阅读更多
从文本导入
Sub Initialize
       On Error Goto UnknowError
       Msgbox "开始导入"
       Dim session As New NotesSession
       Dim db As NotesDatabase
       Dim view As NotesView
       Dim doc As NotesDocument
       Dim docPerson As NotesDocument
       Dim docTemp As NotesDocument
       Dim vFile As Variant
       Dim strMyname As String
       Dim strDeptNO As String
       Dim strDeptName As String
       Dim strFile As String
       Dim V1 As String
       Dim NO,myname,sex,deptNo,deptName,duty,office,phone,mobile,fax,mail,IP,postalcode,address,remark As String
      
       Set db=session.CurrentDatabase
       Set doc=session.DocumentContext
       vFile =Evaluate({@AttachmentNames},doc)
       strFile =Cstr(vFile(0))
       Msgbox strFile
       Dim ebd As NotesEmbeddedObject
       Set ebd=doc.GetAttachment(strFile)
       Msgbox ebd Is Nothing
       Call ebd.extractFile(strFile )
       Open strFile For Input As 10
       Dim i As Integer
       i=1
       If Not Eof(10) Then
              Input #10,V1
       End If
continue: Do While Not Eof(10)
              Input #10,V1
              If V1="" Then
                     Goto continue
              Else
                     myname=Strtoken(V1," ",1)
                     sex=Strtoken(V1," ",2)
                     deptName=Strtoken(V1,"      ",3)
                     duty=Strtoken(V1,"       ",4)
                     office=Strtoken(V1,"     ",5)
                     phone=Strtoken(V1,"     ",6)
                     mobile=Strtoken(V1,"    ",7)
                     fax=Strtoken(V1," ",8)
                     mail=Strtoken(V1," ",9)
                     IP=Strtoken(V1,"   ",10)
                     postalcode=Strtoken(V1,"      ",11)
                     address=Strtoken(V1,"   ",12)
                     remark=Strtoken(V1,"    ",13)
              End If
              If myname="" Then
                     Print {<script>alert("第} & i & {条记录姓名为空,未导入");history.go(-1);</script>}
                     Goto continue
              End If
              If deptName="" Then
                     Print {<script>alert("第} & i & {条记录部门名称为空,未导入");history.go(-1);</script>}
                     Goto continue
              End If
              If phone="" Then
                     Print {<script>alert("第} & i & {条记录固定电话为空,未导入");history.go(-1);</script>}
                    
                     Goto continue
              End If
              If mobile="" Then
                     Print {<script>alert("第} & i & {条记录手机号码为空,未导入");history.go(-1);</script>}
                     Goto continue
              End If
              Set docPerson=db.CreateDocument
              docPerson.form="PersonInfo"
              docPerson.myName=myname
              docPerson.sex=sex
              docPerson.dept=deptName
              docPerson.duty=duty
              docPerson.office=office
              docPerson.phone=phone
              docPerson.mobile=mobile
              docPerson.fax=fax
              docPerson.mail=mail
              docPerson.IP=IP
              docPerson.postalcode=postalcode
              docPerson.address=address
              Dim ritem As NotesRichTextItem
              Set ritem=New NotesRichTextItem(docPerson,"remark")
              ritem.text=remark
              Call docPerson.Save(True,False)
       Loop
       Close #10
       Kill strFile
       Print {<script>alert("导入成功")</script>}
       Exit Sub
UnknowError:
       Msgbox "错误行:" & Erl & "错误信息:" & Error
       Exit Sub
End Sub

b)          Excel导入到notes中
Dim session     As New notessession
       Dim db          As notesdatabase
       Dim view        As notesview
       Dim doc         As notesdocument
       Dim tempdoc     As notesdocument
       Dim w           As New notesuiworkspace
       Dim authorsItem As NotesItem
       Dim collection As NotesDocumentCollection
       Dim v(0)        As String
       Dim r           As Integer
       Dim xlapp       As Variant
       Dim xlbook      As Variant
       Dim xlsheet     As Variant
      
       Set db = session.CurrentDatabase
       Set collection = db.UnprocessedDocuments
       Set doc = collection.GetFirstDocument()
      
       Eval = Evaluate(|@IsNotMember("[Administrator]";@UserRoles)|,doc) '用户执行操作时的判断权限
       If Eval(0) = 1 Then
              Msgbox "对不起,您无权使用此权限!请与管理员联系",0+16,"提示"
              Exit Sub
       End If
      
REM 导入数据时,不采用绝对的路径和文档名称
       Dim files As Variant
       files = w.OpenFileDialog(True, "打开Excel文档","", "D:")
       Set db = session.currentdatabase
       If Isempty(files(0)) Then
              Exit Sub
       Else
              Set xlApp = CreateObject("Excel.Application")         '创建Excel应用类
              xlApp.Visible = False                                 '设置Excel为不可见
              Set xlBook = xlApp.Workbooks.Open(files(0))           '打开Excel工作薄
             
             
REM 设置打开Excel的第几个工作表
              num =Cstr(Inputbox$("请问您想导入的工作表为第几个?"))
              If num = "" Then
                     Exit Sub
              End If    
              a = Cint(num)
              Set XlSheet = xlBook.Worksheets(a)                     '打开Excel工作表
       End If
      
       r = 4
       While Not Cstr(xlsheet.cells(r,1).value) = ""
              Set doc = New NotesDocument(db)
             
              doc.Form       = "shenqing"
              doc.date_1     = xlsheet.cells(r,1).value              '申请日期
              doc.Deft       = xlsheet.cells(r,2).value              '申请部门
              doc.Text_5     = xlsheet.cells(r,3).value              '申请工作区域
              doc.Text_1     = xlsheet.cells(r,4).value              '来访人员姓名
              doc.CheckBox_2 = xlsheet.cells(r,5).value              '来访人员有效证件名称
              doc.Text_2     = xlsheet.cells(r,6).value              '来访人员有效证件号码
              doc.Text_3     = xlsheet.cells(r,7).value              '来访人员公司名称
              doc.sdate      = xlsheet.cells(r,8).value              '工作有效期限
              doc.Text_9     = xlsheet.cells(r,9).value              '发放证件编号
             
              r = r+1
              Print r
             
REM "编号的生成"
              DateKey1 = Cstr(Format(doc.date_1(0),"yyyy"))          '取原始数据中的年
              DateKey2 = Cstr(Format(doc.date_1(0),"mm"))            '取原始数据中的月
              DateKey3 = Cstr(Cint(DateKey1))+"-"+Cstr(Cint(DateKey2))
             
              DateKey = DateKey1+DateKey2
             
              Dim Numview As NotesView
              Dim Numdoc As NotesDocument
              Dim vc As NotesViewEntryCollection
              Dim entry As NotesViewEntry
             
              Set Numview = db.GetView( "AllByNumber" )
              Call Numview.refresh
              Set vc = Numview.GetAllEntriesByKey(DateKey3,True)
             
              doc.import = 1                                                          '设置表单数据倒入时的参数
              doc.date = ""                                           '使数据导入后,打开表单时不显示表单创建的时间
             
              If vc.count =0 Then
                     doc.Number = DateKey+"001"
              Else
                     Set entry = vc.GetFirstEntry()
                     Set Numdoc = entry.Document
                     K = Cint(Right(Numdoc.Number(0),3))+1
                     If K <10 Then
                            Key1 = "00"+Cstr(K)
                     Elseif K<100 Then
                            Key1 = "0"+Cstr(K)
                     Else
                            Key1 = Cstr(K)
                     End If
                     doc.Number = DateKey+Key1
              End If                 
              doc.SaveOptions = "1"
              Call doc.save(False,True)
             
              If doc.Text_9(0) <> "" Then                               '流程参数设置
                     doc.lei = "已完成"        
                     doc.actionnumber = "-1"
                     doc.statu = 2                      
                     doc.saveoptions = "1"
                     Call doc.save(False,True)
              End If
       Wend
      
       Call xlbook.close(True)
       Call xlapp.quit
       Msgbox"导入完毕",0+32,"提示"

c)           Excel导入notes之java版本
import lotus.domino.*;
import java.io.*;
import java.util.Vector;
import jxl.*;
import java.io.PrintWriter;
                       
public class JavaAgent extends AgentBase {

       public void NotesMain() {
              System.out.println("11111111");
              Session ss = getSession();
          String srcFile = null;
              String s=null;
              Workbook rwb = null;
          Document doc = null;
          //'Cell ck0 = null;
              InputStream inps = null;
              Sheet rs=null;
              int totalnum=0;
              System.out.println("2222222222");
              PrintWriter pw = getAgentOutput();
              EmbeddedObject ebd = null;
              File f=null;                   
              try {
                     System.out.println("33333333333333");
                     AgentContext agt = ss.getAgentContext();
                     Document cdoc = agt.getDocumentContext();
                     Database cdb = agt.getCurrentDatabase();
                     DocumentCollection dc = null;
                     Agent ag=null;
                     String strdata = null;
                     String strContent = null;
                     Double dob=null;
                     StringBuffer tmpstr=new StringBuffer("1");
                    
                     Vector vtr = ss.evaluate("@AttachmentNames",cdoc);
               srcFile =new String(""+vtr.get(0).toString());
               ebd = cdoc.getAttachment(srcFile);
                       System.out.println(srcFile);
                            ebd.extractFile(srcFile);
                          System.out.println("44444444asdfasdf");
                           
                            //ebd.recycle();
                            //创建文件流,然后输出excel表格
                            inps = new FileInputStream(srcFile);
                            rwb = Workbook.getWorkbook(inps);
                    if (ebd==null)
                               {
                                    rwb.close();
                                 rwb = null;
                           return;
                       }
                            if (ebd.getType()!=EmbeddedObject.EMBED_ATTACHMENT)
                      {
                             rwb.close();
                                   rwb = null;
                             return;
                      }
                            //读取第一张sheet

                            rs = rwb.getSheet(0);
                                       
                            Vector errRecord = new Vector();

                    for (int k=1;k<rs.getRows();k++)
                     {
                         System.out.println("44444444444444444444");
                    
                           Cell ck0 = rs.getCell(0,k);
                           Cell ck1 = rs.getCell(1,k);
                           Cell ck2 = rs.getCell(2,k);
                           Cell ck3 = rs.getCell(3,k);
                           Cell ck4 = rs.getCell(4,k);
                           Cell ck5 = rs.getCell(5,k);
                           Cell ck6 = rs.getCell(6,k);
                           Cell ck7 = rs.getCell(7,k);
                           Cell ck8 = rs.getCell(8,k);
                           Cell ck9 = rs.getCell(9,k);
                           Cell ck10 = rs.getCell(10,k);
                           Cell ck11 = rs.getCell(11,k);
                           Cell ck12 = rs.getCell(12,k);
                           Cell ck13 = rs.getCell(13,k);                    
                          
                           if(!ck0.getContents().equals(""))
                           {  
                               System.out.println("55555555");
                               doc=cdb.createDocument();
                               doc.appendItemValue("Form", "PersonInfo");
                                if(!ck0.getContents().equals(""))
                                {
                                  doc.appendItemValue("NO", ck0.getContents());
                                 }
                              if(!ck1.getContents().equals(""))
                                {
                                  doc.appendItemValue("myname",ck1.getContents());
                                 }
                                  if(!ck2.getContents().equals(""))
                                {
                                  doc.appendItemValue("sex", ck2.getContents());
                                 }
                                  if(!ck3.getContents().equals(""))
                                {
                                 doc.appendItemValue("dept", ck3.getContents());
                             
                                 }
                                  if(!ck4.getContents().equals(""))
                                {
                                  doc.appendItemValue("duty", ck4.getContents());
                              
                                 }
                                  if(!ck5.getContents().equals(""))
                                {
                                 doc.appendItemValue("office", ck5.getContents());
                              
                                 }
                                  if(!ck6.getContents().equals(""))
                                {
                                 doc.appendItemValue("phone", ck6.getContents());
                             
                                 }
                                  if(!ck7.getContents().equals(""))
                                {
                                  doc.appendItemValue("mobile", ck7.getContents());
                             
                                 }
                                  if(!ck8.getContents().equals(""))
                                {
                                  doc.appendItemValue("fax", ck8.getContents());
                              
                                 }
                                
                                  if(!ck9.getContents().equals(""))
                                {
                                 doc.appendItemValue("mail", ck9.getContents());
                              
                                 }
                                  if(!ck10.getContents().equals(""))
                                {
                                 doc.appendItemValue("IP", ck10.getContents());
                              
                                 }
                                  if(!ck11.getContents().equals(""))
                                {
                                 doc.appendItemValue("postalcode", ck11.getContents());
                             
                                 }
                                  if(!ck12.getContents().equals(""))
                                {
                                  doc.appendItemValue("address", ck12.getContents());
                             
                                 }
                                  if(!ck13.getContents().equals(""))
                                {
                                  RichTextItem rtitem = doc.createRichTextItem("remark");
                                  doc.appendItemValue("remark", ck13.getContents());
                                 }
                               if (doc.save())
                                   System.out.println("Document has been saved");
                                else
                                  System.out.println("Unable to save document");
                                    }
                            }
                           
              } catch(Exception e)
              {
                     System.out.println("error>>>>>"+e);
                    
                  }
      finally {  
                                   rwb.close();
                                   try
                                   {
                                          inps.close();
                                          boolean success = (new File(srcFile)).delete();
                                   }
                                   catch(Exception ex)
                                   {
                                          System.out.println(ex);
                                   }
                     }

       }

}
分享到:
评论

相关推荐

    outlook联系人导入lotus notes

    以下是一个详细的教程,教你如何将Outlook的联系人导入Lotus Notes。 首先,你需要在Outlook中导出联系人。这可以通过以下步骤实现: 1. 启动Outlook并进入“联系人”视图,确保你能够看到所有的联系人条目。 2. ...

    配置IBM Lotus Notes 8.5 Client

    此外,您还可以使用 IBM Lotus Notes 8.5 Client 来设置自动复制时间,以便您可以定期地备份您的邮箱数据。 配置 IBM Lotus Notes 8.5 Client 需要您按照上述步骤进行操作。本文提供了详细的配置步骤,以帮助您快速...

    LotusXSL.zip_liaisonparser_lotus notes_lotusxsl_notes_zip

    此外,它可能还支持XML数据的导入,使得非Notes系统能够与Notes数据库进行数据交换。 "www.pudn.com.txt"可能是一个包含版权信息、许可协议或其他相关信息的文本文件,因为"PUDN"是一个分享技术资源的网站。"META-...

    Sercomm China Lotus Notes 8 基本安裝設定

    - 推荐将 Lotus Notes 8 安装到 `D:\Lotus\Notes\` 目录,并将数据文件安装到 `D:\Lotus\Notes\Data\` 目录下。 5. **选择安装组件**: - 在安装功能选择界面,勾选“客户端单一用户登录”选项,并继续进行安装。...

    IBM Lotus Notes 8.5 Reviewer's Guide

    除了iCalendar源外,Lotus Notes 8.5还支持将公共Google日历中的事件导入到Notes日历中,进一步增强了跨平台的协作能力。 **1.3.4 日历视图中的水平滚动条** 新的水平滚动条功能让用户能够在查看月视图时轻松滑动...

    如何将Outlook邮件导入Lotus的操作技巧.pdf

    ### 如何将Outlook邮件导入Lotus的操作技巧 在企业级环境中,经常会出现不同电子邮件系统之间的数据迁移需求,比如从Microsoft Outlook向IBM Lotus Notes(现称为HCL Domino)的迁移。这种需求通常源于公司内部软件...

    Lotus-Notes文档数据库[参考].pdf

    Notes Pump是一个用于在Lotus Notes和关系数据库之间进行数据传输的工具,它支持数据的导入和导出。Notes Pump可以连接不同的RDBMS系统,通过ODBC接口进行数据同步。 Lotus Enterprise Integrator(LEI)是IBM提供...

    中文 lotus Notes R5 24学时教程(1-12)

    - Lotus Notes R5可以与其他IBM产品(如Domino Server)集成,提供更丰富的功能,如Web发布、数据库同步和外部数据源连接。 10. **系统管理和维护**: - 学习如何管理Notes客户端设置,包括配置代理、邮件服务器...

    IBM Lotus Notes and Domino 8 Deployment Guide

    ### IBM Lotus Notes and Domino 8 部署指南核心知识点概览 #### 一、IBM Lotus Notes and Domino 8 概述 IBM Lotus Notes 和 Domino 8 是一套强大的企业级协作平台,它提供了全面的电子邮件、日历、联系人管理、...

    LotusNotes6.5配置[整理].pdf

    #### 三、模板与数据导入 8. **导入模板与数据**: - 从网络路径`\\192.168.201.55\toyo\Personnel\Lu Yingqin\notes`中复制`names.nsf`、`tec.nsf`、`tec_global.nsf`以及文件夹`tchina`至Lotus Notes的数据目录`...

    lotus命令集lotus命令集lotus命令集lotus命令集

    2. `nsfdata`命令:用于处理Notes数据库的数据,如导出、导入和比较。 五、 Lotus Notes安全和权限管理 1. `ACL`(Access Control List):控制用户和组对数据库的访问权限。 2. `Deny`和`Allow`设置:分别限制和...

    升级Notes8方法

    以上就是升级 Lotus Notes 8 的完整过程,包括升级前的用户信息确认、软件安装、数据导入以及应用恢复等关键步骤。每个环节都需要注意,以确保无缝过渡并保持数据的完整性。在执行这些步骤时,务必细心操作,并在...

    lotus数据用java程序导入导出实现数据移置的方案

    本方案介绍了一种使用 Java 语言来实现 Lotus 数据导入导出的方法,并特别关注了如何处理附件数据。 #### 关键技术点与步骤 ##### 1. 获取配置信息 首先,通过 `ResourceBundle` 获取配置文件中的相关信息,包括...

    Lotus Domino 8.5中的DAOS备份和恢复

    "Lotus Domino 8.5中的DAOS备份和恢复" DAOS(DatabaseAnchor Object Storage)是一种基于磁盘的附件存储机制,旨在提高 Lotus Domino 服务器的存储效率和可扩展性。DAOS 通过将附件存储在独立的文件中,而不是存储...

    lotus ID

    1. **创建和管理ID**:使用Lotus Notes Administrator或命令行工具如iNotes Utility来创建、导入、导出和更新ID。 2. **安全性和备份**:定期备份ID以防丢失,并确保只有授权人员可以访问ID文件。 3. **调试和权限...

    notes归档文件转outlook软件

    标题提到的"notes归档文件转outlook软件"就是解决此类问题的工具,它能够帮助用户方便地将Notes的归档数据导入到Outlook环境。 Lotus Notes和Outlook都是广泛使用的电子邮件客户端,但它们的数据格式并不兼容。因此...

    Lotus Domino BS开发 --Lotus历史简介

    Lotus Domino的起源可以追溯到20世纪70年代的伊利诺斯州立大学,那时的PLATO Notes系统是它的前身。PLATO Notes开创了用户间安全通信的概念,而1976年的PLATO Group Notes进一步发展了这一概念,允许用户创建主题...

    lotus5---3

    4. **Lotus 1-2-3电子表格应用**:介绍数据分析、公式编写、图表制作和数据导入导出等功能。 5. **Lotus Freelance Graphics演示文稿**:教授如何制作专业级别的幻灯片,包括图形编辑、模板应用和过渡效果设置。 6. ...

Global site tag (gtag.js) - Google Analytics