lotus客户端导出Excel

Option Public
Option Declare

Sub Initialize
	On Error GoTo Errhandle
	Dim ss As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim docs As NotesDocumentCollection
	Dim tdoc As NotesDocument
	Dim ventry As NotesViewEntry
	Dim vns As NotesViewEntryCollection
	
	
	Set db=ss.Currentdatabase
	Set view=db.Getview("viewArcDocForExcel")
	Set docs=view.Getalldocumentsbykey("请假申请", 1)
	
	Set tdoc =docs.Getfirstdocument()

	
	Dim excelApp As Variant
	Dim excelSheet As Variant
	Set excelApp=CreateObject("excel.application")
	excelApp.statusbar="正在创建工作表,请稍等......"
	excelApp.visible=False
	excelApp.workbooks.Add
	'excelApp.Visible = True
	excelApp.referencestyle=2
	Set excelSheet=excelApp.workbooks(1).worksheets(1)
	excelSheet.name="请假统计"

	'增加标题
	excelApp.Range("A1:D1").Select        '指定列的范围   
    excelApp.selection.Merge   
    excelApp.selection.Rows.Rows(1).RowHeight=40 
	excelApp.selection.HorizontalAlignment =3     '左右居中 
	excelApp.selection.VerticalAlignment=2         '上下居中 
	excelApp.selection.Font.name = "康书"           '字体 
	excelApp.selection.Font.size = "18"            '大小  
	excelApp.selection.Font.Bold =True            '加粗   
	excelApp.ActiveCell.FormulaR1C1 = "请假统计表"    '赋值 

	excelApp.Range("A2").Select  
	excelApp.selection.Merge   
	excelApp.selection.font.size="10" 
	excelApp.selection.RowHeight=27 
	excelApp.selection.Font.Bold =True 
	excelApp.selection.HorizontalAlignment =3 '左右居中
	excelApp.selection.VerticalAlignment=2  '上下居中
	excelApp.selection.Font.name = "宋体"  '字体
	excelApp.selection.columnwidth="10"  '当前列宽
	excelApp.selection.RowHeight=27  '  当前行高
	excelApp.ActiveCell.FormulaR1C1 = "请假类型"  '赋值
	excelApp.selection.Interior.ColorIndex= 55  '表格底色55表示深蓝色
	excelApp.selection.font.ColorIndex= 2  '字体颜色2表示白色
	excelApp.Selection.Borders.LineStyle = 1 '线格

	excelApp.Range("B2").Select  
	excelApp.selection.Merge   
	excelApp.selection.font.size="10" 
	excelApp.selection.RowHeight=27 
	excelApp.selection.Font.Bold =True 
	excelApp.selection.HorizontalAlignment =3 '左右居中
	excelApp.selection.VerticalAlignment=2  '上下居中
	excelApp.selection.Font.name = "宋体"  '字体
	excelApp.selection.columnwidth="10"  '当前列宽
	excelApp.selection.RowHeight=27  '  当前行高
	excelApp.ActiveCell.FormulaR1C1 = "请假类型"  '赋值
	excelApp.selection.Interior.ColorIndex= 55  '表格底色55表示深蓝色
	excelApp.selection.font.ColorIndex= 2  '字体颜色2表示白色
	excelApp.Selection.Borders.LineStyle = 1 '线格
	
	excelApp.Range("C2").Select  
	excelApp.selection.Merge   
	excelApp.selection.font.size="10" 
	excelApp.selection.RowHeight=27 
	excelApp.selection.Font.Bold =True 
	excelApp.selection.HorizontalAlignment =3 '左右居中
	excelApp.selection.VerticalAlignment=2  '上下居中
	excelApp.selection.Font.name = "宋体"  '字体
	excelApp.selection.columnwidth="10"  '当前列宽
	excelApp.selection.RowHeight=27  '  当前行高
	excelApp.ActiveCell.FormulaR1C1 = "请假天数"  '赋值
	excelApp.selection.Interior.ColorIndex= 55  '表格底色55表示深蓝色
	excelApp.selection.font.ColorIndex= 2  '字体颜色2表示白色
	excelApp.Selection.Borders.LineStyle = 1 '线格
	
	excelApp.Range("D2").Select  
	excelApp.selection.Merge   
	excelApp.selection.font.size="10" 
	excelApp.selection.RowHeight=27 
	excelApp.selection.Font.Bold =True 
	excelApp.selection.HorizontalAlignment =3 '左右居中
	excelApp.selection.VerticalAlignment=2  '上下居中
	excelApp.selection.Font.name = "宋体"  '字体
	excelApp.selection.columnwidth="10"  '当前列宽
	excelApp.selection.RowHeight=27  '  当前行高
	excelApp.ActiveCell.FormulaR1C1 = "请假日期"  '赋值
	excelApp.selection.Interior.ColorIndex= 55  '表格底色55表示深蓝色
	excelApp.selection.font.ColorIndex= 2  '字体颜色2表示白色
	excelApp.Selection.Borders.LineStyle = 1 '线格

	
	Dim rows As Integer
	rows=3
	
	
	
	While Not tdoc Is Nothing 
		excelSheet.Cells(rows,1).value=tdoc.AddName(0)
		excelSheet.Cells(rows,2).value=tdoc.qjlx(0)
		excelSheet.Cells(rows,3).value=tdoc.hjts(0)
		excelSheet.Cells(rows,4).value=CStr(tdoc.DocPostTime(0))
		Set tdoc=docs.Getnextdocument(tdoc)
		rows=rows +1
	Wend
	excelSheet.Columns("A:D").EntireColumn.AutoFit
	excelApp.statusbar="就绪"
	excelApp.ActiveWorkbook.SaveCopyAs("D:\zb.xls")
	excelApp.DisplayAlerts = False 
	excelApp.Quit 
	Set excelApp = Nothing
	Exit sub
Errhandle:
	print Error 	& CStr(Erl)
	
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值