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): 17683/ 207

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

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 7 and 8 and type the answer here:

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






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


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 11/21/2008 7:01:33 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search