如何将Excel中的数据导入Notes数据库,急~~~~~~~~~~

eino 2003-03-03 03:48:24
将Excel中的数据导入Notes数据库,以视图的方式显示出来??谢了!!
最好给一个成型的例子库,可以发到邮箱中eino@163.com,谢了!!
...全文
15 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jhlqab 2003-03-03
Sub Click(Source As Button)
Dim s As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim dc As notesdocumentcollection
Dim doc As notesdocument
Dim vcols As Variant
Dim uvcols As Integer

Set db = s.currentdatabase
Set dc = db.unprocesseddocuments
Set view = db.getview("当前视图的名称")
uvcols=Ubound(view.columns)

Dim xlapp As Variant
Dim xlsheet As Variant
'创建一个Excel对象
Set xlapp=createobject("Excel.application")
xlapp.statusbar = "正在创建工作表,请稍等......"
xlapp.visible = True
'添加工作薄
xlapp.workbooks.add
xlapp.referencestyle = 2
Set xlsheet = xlapp.workbooks(1).worksheets(1)
'为工作表命名
xlsheet.name = "notes export"
Dim rows As Integer
rows = 1
Dim cols As Integer
cols = 1
Dim maxcols As Integer
For x=0 To Ubound(view.columns)
xlapp.statusbar = "正在创建单元格,请稍等......"
If view.columns(x).IsHidden = False Then
If view.columns(x).title<>"" Then
xlsheet.cells(rows,cols).value = view.columns(x).title
cols = cols + 1
End If
End If
Next
maxcols=cols-1

Set doc=dc.getfirstdocument
Dim fieldname As String
Dim fitem As notesitem
rows=2
cols=1

Do While Not(doc Is Nothing)
For x=0 To Ubound(view.columns)
xlapp.statusbar="正在从Notes中引入数据,请稍等......"
If view.columns(x).IsHidden=False Then
If view.columns(x).title<>"" Then
fieldname = view.columns(x).itemname
Set fitem = doc.getfirstitem(fieldname)
xlsheet.cells(rows, cols).value = fitem.text
cols = cols +1
End If
End If
Next
rows = rows+1
cols = 1
Set doc= dc.getnextdocument(doc)
Loop

%REM
xlApp.Row s("1:1").select
xlApp.Selection.Font.Bold=True
xlApp.Range(xls heet.cells(1,1),xlsheet.Cells(rows,maxcols)).Select
xlApp.Selection.Fon t.Name="Arial"
xlApp.Selection.Font.Size=9
xlApp.Selcetion.Col umns.Autofit
%END REM

With xlapp.worksheets(1)
.pagesetup.orientation = 2
.pagesetup.centerheader = "report _ confidential"
.pagesetup.rightfooter = "page &P" & Chr$(13) & "Date:&D"
.pagesetup.CenterFooter = ""
End With

xlapp.referencestyle = 1
xlapp.range("A1").Select
xlapp.statusbar = "数据导入完成。"
End Sub
回复
wealwolf 2003-03-03
可以真接用Excel VBA对象,具体请看VBA帮助
回复
发动态
发帖子
消息协作
创建于2007-08-27

520

社区成员

企业开发 Exchange Server
申请成为版主
社区公告
暂无公告