zoukankan      html  css  js  c++  java
  • 关于WORD文档的导出

     1 Public Class ExportWord
     2 
     3     Dim wordApp As Word.Application = New Word.Application()
     4     Dim wordDocu As Word.Document = New Word.Document()
     5     Dim myNothing As Object = Missing.Value
     6 
     7     Public Function CreateWord() As Boolean
     8         wordDocu = wordApp.Documents.Add(myNothing, myNothing, myNothing, myNothing)
     9 
    10         '添加页眉
    11         wordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView
    12         wordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader
    13         wordApp.Selection.InsertAfter("*****服务热线")
    14         wordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
    15         '跳出页眉设置
    16         wordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument
    17 
    18         '插入文字,设置字体样式
    19         wordApp.Application.Selection.Font.Size = 12
    20         wordApp.Application.Selection.Font.Bold = 5
    21         wordApp.Application.Selection.Font.Color = WdColor.wdColorBlack
    22         wordApp.Application.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
    23         wordApp.Application.Selection.TypeText("二○一三年十月份**热线情况说明")
    24 
    25         '换行
    26         wordApp.Application.Selection.TypeParagraph()
    27 
    28         '插入图片
    29         wordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
    30         wordApp.Application.Selection.InlineShapes.AddPicture("C:WindowsWebWallpaperWindows1 (3).jpg", myNothing, myNothing, myNothing)
    31 
    32         '保存文件
    33         Dim myFileName = "C:UsersAdministratorDesktop1.doc"
    34         Dim myWordFormatDocument As Object = Word.WdSaveFormat.wdFormatDocument
    35         Dim myLockd As Object = False
    36         Dim myPassword As Object = ""
    37         Dim myAddto As Object = True
    38         Try
    39             wordDocu.SaveAs(myFileName, myWordFormatDocument, myLockd, myPassword, myAddto, myPassword, myLockd, myLockd, myLockd, myLockd, myNothing, myNothing, myNothing, myNothing, myNothing, myNothing)
    40 
    41         Catch ex As Exception
    42 
    43         End Try
    44 
    45     End Function
    46  
    47 End Class
  • 相关阅读:
    Quartz.Net 学习随手记之04 构建Windows Service承载服务
    Quartz.Net 学习随手记之03 配置文件
    SQL Server问题之计算机名称更改后无法登陆本地数据库
    SQL Server问题之The remote procedure call failed. [0x800706be]
    跨框架菜单menuG5使用
    DLink 524M经常断线、掉线问题的解决
    MSChart使用导航之开发
    ReSharper制作Template帮助我们快速输入代码
    网站右下角弹出通知效果的制作
    Dell6400拆卸与维护
  • 原文地址:https://www.cnblogs.com/itzhanghb/p/3623194.html
Copyright © 2011-2022 走看看