Review: SoftArtisans OfficeWriter v3
page 6 of 9
by Jesudas Chinnathampi (Das)
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 36772/ 40

Creating a Word File Based on a Template

A Word document can be created with the help of following VB.NET code:

Dim NamesArr As String() = {"Name", "Company", "DateTime"}
' Form an array containg the values to be inserted 
Dim ValuesArr As Object() = {recipName, recipCompany, System.DateTime.Now}
' Create an instance of WordTemplate 
Dim wt As WordTemplate = New WordTemplate
' Open the template document 
Dim templatePath As String = Page.MapPath("templates/BasicTemplate.doc")
wt.Open(templatePath)
' Set the main data source with the Name and Value arrays 
wt.SetDataSource(ValuesArr, NamesArr)
' Populate the template to pull in the new values 
wt.Process()
' Save the document by streaming it
wt.Save(Page.Response, "BasicWordTemplate.doc", False)


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-20 9:37:41 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search