利用notes客户端将 excel 倒入 domino数据库

该博客以简单资产库为例,介绍了将Excel内容导入Notes数据库的方法,同时支持多个sheet的Excel文件同时导入。文中给出了具体的代码实现,包括文件选择、数据读取和文档保存等操作。

该例以简单的资产库为背景,可以将excel的内容导入到notes数据库,同时也实现了多个sheet的excel的同时导入

Sub Click(Source As Button) 
 
'-------------------------------------------------------------
'-- Admin 资产导入--
'-------------------------------------------------------------
 
 Dim ws As New notesuiworkspace
 Dim ss As New notessession
 Dim db As notesdatabase
 Dim item As notesitem
 Dim files As Variant
 Dim schar As String
 Dim doc As NotesDocument
 Dim cpdoc As NotesDocument
 Dim excelapplication
 Dim i,sheet
  
 Set db = ss.currentdatabase
  
 files = ws.openfiledialog(False,"请选择要导入的Excel文件","Excel file/*.xls")
 
 sheeet = 1
 
 If Not(Isempty(files)) Then
  Set excelapplication = createobject("excel.application")
  Set excelworkbook = excelapplication.workbooks.open(files)
  

  '多个sheet循环
  Do Until Cstr(excelsheet.cells(i,sheet).value) =""
   
   Set excelsheet = excelworkbook.worksheets(1)
   i = 2
  

   '一个sheet里面所有记录循环
   Do Until Cstr(excelsheet.cells(i,1).value) =""
    Set cpdoc = New notesdocument(db)
    cpdoc.Form = "assets"

    
    cpdoc.import_flag = Str(Today())    '指定导入批次为导入日期
    
    cpdoc.NumberID = excelsheet.cells(i,1).value
    cpdoc.company = excelsheet.cells(i,2).value
    cpdoc.Type = excelsheet.cells(i,3).value
    cpdoc.Admin_NumberID = excelsheet.cells(i,4).value
    cpdoc.state = excelsheet.cells(i,5).value    
    cpdoc.ID = excelsheet.cells(i,6).value
    cpdoc.date = excelsheet.cells(i,7).value
    cpdoc.Area = excelsheet.cells(i,8).value
    cpdoc.location = excelsheet.cells(i,9).value
    cpdoc.pc = excelsheet.cells(i,10).value
          
    Call cpdoc.save(False,False)

   Loop
  Loop
 
  excelworkbook.close(False)
  excelapplication.quit
  Set excelapplication = Nothing
  
 End If
 
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值