当前位置: 代码迷 >> Lotus >> 请问:NOTES导入导出EXCEL的有关问题(不是视图的方式,而是当前文档)
  详细解决方案

请问:NOTES导入导出EXCEL的有关问题(不是视图的方式,而是当前文档)

热度:107   发布时间:2016-05-05 07:18:14.0
请教:NOTES导入导出EXCEL的问题(不是视图的方式,而是当前文档)

在网上找的,都是一堆通过视图的方式导入导出,有没有通过当前打开的表单的代码?
请高手赐教。 


------解决方案--------------------
Dim xlApp As Variant
Set xlApp = CreateObject("Excel.application")
strTemplateFilePath="C:\test.xls"

'\\ for export to Excle
xlApp.Workbooks.Add(strTemplateFilePath)

xlApp.Workbooks(1).Worksheets( intSheet ).Cells( row , column).Select
xlApp.Selection.NumberFormatLocal = "@"
xlApp.Workbooks(1).Worksheets( intSheet ).Cells( row , column).Value = doc.NotesField(0)

'\\ for import to Notes
xlApp.Workbooks.Open(strTemplateFilePath)
doc.NotesField=xlApp.Workbooks(1).Worksheets( intSheet ).Cells( row , column ).Value

变量strTemplateFilePath , intSheet , row , column, doc, NotesField,根据自己的实际情况修改.
------解决方案--------------------
Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim SourceDoc As NotesDocument
Set uidoc = uiws.CurrentDocument
Set SourceDoc = uidoc.Document

这就抓到当前文档啦,你再从当前文档导出Excel就OK了

还有不会请电联
------解决方案--------------------
Sub Initialize
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim vw As NotesView
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim pdoc As NotesDocument
Dim dr As String
Dim fn As String
Dim filename As String
Dim rows As Integer

Set db=ss.CurrentDatabase
Set vw=db.GetView("vwCaseFinish")
Set doc=ss.DocumentContext

Set dc=vw.GetAllDocumentsByKey(Cstr(Strright(Strleft(doc.fldCurrentUser(0),"/O=yhfund"),"CN=")),True)

Dim excelApp As Variant
Dim excelWorkbook As Variant
Dim excelSheet As Variant

Set excelApp=CreateObject("Excel.Application")
excelApp.Visible = True
Set excelWorkbook = excelApp.Workbooks.Add
Set excelSheet = excelWorkbook.Worksheets("Sheet1")

excelSheet.Cells(1,1).Value="任务标示"
excelSheet.Cells(1,2).Value="创建人"
excelSheet.Cells(1,3).Value="所属流程"
excelSheet.Cells(1,4).Value="创建时间"
excelSheet.Cells(1,5).Value="待办人员"
excelSheet.Cells(1,6).Value="状态"
excelSheet.Cells(1,7).Value="当前环节"

rows=1
Set pdoc=dc.GetFirstDocument
While Not (pdoc Is Nothing)
rows=rows+1
excelSheet.Cells(rows,1).Value=pdoc.GetItemValue("OKCaseTag")(0)
excelSheet.Cells(rows,2).Value=pdoc.GetItemValue("OKCaseCreater")(0)
excelSheet.Cells(rows,3).Value=pdoc.GetItemValue("OKCASEAPP")(0)
excelSheet.Cells(rows,4).Value=pdoc.GetItemValue("OKCaseStart")(0)
excelSheet.Cells(rows,5).Value=pdoc.GetItemValue("OKWaitingUser")(0)
excelSheet.Cells(rows,6).Value=pdoc.GetItemValue("OKCaseStatus")(0)
excelSheet.Cells(rows,7).Value=pdoc.GetItemValue("OKCaseTask")(0)
Set pdoc=dc.GetNextDocument(pdoc)
Wend
execel.quit
Set execel = Nothing
End Sub
------解决方案--------------------
CreateObject("Excel.Application") 是一种常见的方法,还有一种比较笨拙的就是自己拼成HTML。
然后 Print |Content-Type:application/vnd.ms-excel;charset=GB2312|
Print |Content-Disposition:attachment;filename=|+fileName+|.xls|
print html
  相关解决方案