根据DocX官方描述如下:

In the application development process, it uses COM libraries and requires MS Word or Office to be installed when generates the word report.

In an easy and intuitive manor,DocX is fast, lightweight and best of all it does not require MS Word or Office to be installed.

And you need to install in order to use DocX is the .NET Framework 4.0, and also reference DocX.dll.

------------------------------Source Code-----------------------------------------------------------------------------------------------------------------------------

Dim tmpPath As String = Server.MapPath("~/template.docx")
Dim outputPath As String = Server.MapPath("~/Output.docx")
Dim productID As String = "Product I.D." & vbTab & vbTab & "32925" & vbCr
Dim productName As String = "Product Name." & vbTab & vbTab & "GESAPRIM GrDA 10KG BAG"

Dim fieldNames As String() =
New String() {"<<site>>", "<<sitecontact>>", "<<siteaddress1>>", "<<siteaddress2>>", "<<siteaddress3>>", "<<GenName>>", "<<body>>", "<<crop>>"}
Dim fieldValues As Object() =
New Object() {"Syngenta Crop Protection LLC", "Dr. Rene Arenas, Quality Manager", "3905 Highway 75", "River Road, St. Gabriel, Louisiana 70776", "E.U.A", "Terrence Zhang", productID, productName}

Using document As DocX = DocX.Load(tmpPath)

For index = 0 To fieldNames.Length - 1 Step +1
document.ReplaceText(fieldNames(index), fieldValues(index))
Next

Dim p As Paragraph = document.InsertParagraph("", False)
Dim img As Novacode.Image = document.AddImage(AppDomain.CurrentDomain.BaseDirectory & "/Images/Tamara Edwards.PNG")
Dim pic As Picture = img.CreatePicture()
p.InsertPicture(pic, 0)
p.Append(vbCr)
p.Append("I am bold").FontSize(11).Bold().Append("1").Script(Script.superscript)

document.SaveAs(outputPath)
End Using
Response.Redirect("~/Output.docx")

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

最新文章

  1. 命令行工具解析Crash文件,dSYM文件进行符号化
  2. svn服务器端的客户端自动更新
  3. python 字符串函数
  4. Write cv::Mat to a file
  5. Spark中加载本地(或者hdfs)文件以及SparkContext实例的textFile使用
  6. Java面试题之六
  7. iOS开发——沙箱
  8. oracle导出dmp文件的2种方法
  9. Python之进度条及π的计算
  10. Service Mesh
  11. 统计nginx日志里访问次数最多的前十个IP
  12. python 报错RuntimeError: dictionary changed size during iteration
  13. jQuery 源码分析:当 selector 传来一个函数时,怎么进行处理?
  14. Python3基础 try-指定except-as reason 捕获打开一个不存在的文件的时候,会产生OSError异常的示例
  15. 安装MySQL-python
  16. AJAX 跨域问题 php
  17. 小Z的袜子(hose) HYSBZ - 2038 (莫队算法)
  18. Appium Python 六:管理应用和Activity
  19. linux下使用gtest框架进行c/c++单元测试
  20. Jumpserver0.5使用说明

热门文章

  1. 使用vsftp服务传输文件
  2. 使用swig工具为go语言与c++进行交互
  3. PythonStudy——Python 内置函数 Built-in function
  4. pyhdfs安装
  5. Mysql 数据库操作之DDL、DML、DQL语句操作
  6. Hexo-Next6.7.0主题优化
  7. 【rabbitmq】Centos7 下安装rabbitmq
  8. 廖雪峰Java7处理日期和时间-3java.time的API-2ZonedDateTime
  9. mkimage command not found – U-Boot images will not be built
  10. ROS--导航、路径规划和SLAM