Introducing SoftArtisans OfficeWriter 3.0 Enterprise, with ASP Features - Generating a Word Document
(Page 3 of 5 )
Let us now work out a short demo of how easy it is to generate a Word document using ASP.NET.
You can use either a plain text editor such as NotePad or Visual Studio .NET. If you decide to work with NotePad, you should place the two DLL files (SAWW3NET.dll & SAXW6NET.dll) inside the bin folder on the working directory. If you work with Visual Studio .NET, you should add references to the above DLL files. With VS.NET, you can take advantage of its IntelliSense feature, which will simplify the coding process.
The first step is to import the required namespaces as shown below:
Imports System
Imports System.Web.UI
Imports SoftArtisans.OfficeWriter.WordWriter
The Word file can be easily generated using the following code:
Namespace SoftArtisans.WordWriter.MyOfficeWriter
Public Class MyWordDoc : Inherits System.Web.UI.Page
Private wordapp As WordApplication
Private docu As Document
Protected Sub Page_Load(sender As Object, e As EventArgs)
TriggerDocument()
End Sub
Private Sub TriggerDocument()
wordapp = New WordApplication()
docu = wordapp.Create()
wordapp.Save(docu, Page.Response, "MyWordDocument.doc", False)
End sub
End Class
End Namespace
Additionally, you can add text to the Word file using the code given below:
docu.InsertTextAfter("This document is generated by SoftArtisans OfficeWriter Enterprise Edition. ", False)
docu.InsertTextAfter("This document is generated using 30 days evaluation edition", False)
The final output will be as shown in the figure given below:

Next: Generating an Excel Document >>
More ASP Articles
More By