Creating Word Documents by Using C# and XML Minnesota

This article tells you how to create word documents in your application without using Office Interop or third-party libraries.

Local Companies

American Software and Global Technologies
(952) 885-5640
1650 W 82nd St
Minneapolis, MN
Assessment Systems
651-647-9220
2233 University Ave W
St. Paul, MN
ePhiphony Incorporated
877-878-7686
4115 Durham Court
Eagan, MN
Global Software
(612) 305-4472
10 S 5th St
Minneapolis, MN
Spyware Blockers nc
651-263-5121
PO Box 130331
Roseville, MN
Sierra Bravo Corporation
952-948-1211
9201 E Bloomington Fwy
Bloomington, MN
Lawson Software
651-767-7000
380 Saint Peter St
St. Paul, MN
Automation Station Inc
651-224-1985
180 5th St E
St. Paul, MN
Science Museum Computer Education Center
(651) 221-4722
120 West Kellogg Blvd.
St. Paul, MN
Interdyn BMI
651-639-0575
2277 West Hwy 36, Suite 300
Roseville, MN

In today's web applications, quite often you run into the need to create a Word document that user can download. The two most common ways of accomplish this is to install a copy of Word with Office Interop on the server or use a third-party library. Both of these options have significant downsides; however, there is a far simpler way to create Word Documents using XML. Because Word natively has the ability to read/write Word documents in XML, you can utilize all of the XML/XSLT tools in .NET to create them.

The first step is to create a normal Word document to be used as a template. Figure 1 shows a simple Word doc with which you will start to produce a report for Sales Territories from the Adventure Works sample database.


Figure 1: Word Document Template

Although this document does not make much sense at this point, you will use the markers in the document to help build the XSLT. To save this document to an XML file, you will need to save the file in the Word 2003 XML Document format shown in Figure 2.


Figure 2: Save as Word XML



Creating the XSLT



Now that you have an XML file, you can start the process of creating an XSLT (EXtensible Stylesheet Language Transformation). First, change the extension of the file from XML to XSLT. Then, open the XSLT in an XML editing tool. Next, you need to add a couple of tags at the top and bottom so that you can call this a XSLT. At this point, the top of the XSLT document should show the following couple of tags:




<?xml version="1.0" encoding="utf-8"?>
<w:wordDocument xmlns:aml=
"http://schemas.microsoft.com/aml/2001/core" ...


Read the Rest of this Article at Developer.com

Featured Local Company

Sierra Bravo Corporation

952-948-1211
9201 E Bloomington Fwy
Bloomington, MN
http://www.sierra-bravo.com

Regional Articles
- Creating Word Documents by Using C# and XML Albert Lea MN
- Creating Word Documents by Using C# and XML Andover MN
- Creating Word Documents by Using C# and XML Anoka MN
- Creating Word Documents by Using C# and XML Bemidji MN
- Creating Word Documents by Using C# and XML Brainerd MN
- Creating Word Documents by Using C# and XML Burnsville MN
- Creating Word Documents by Using C# and XML Champlin MN
- Creating Word Documents by Using C# and XML Chanhassen MN
- Creating Word Documents by Using C# and XML Chaska MN
- Creating Word Documents by Using C# and XML Circle Pines MN
- Creating Word Documents by Using C# and XML Cloquet MN
- Creating Word Documents by Using C# and XML Cottage Grove MN
- Creating Word Documents by Using C# and XML Detroit Lakes MN
- Creating Word Documents by Using C# and XML Duluth MN
- Creating Word Documents by Using C# and XML Eden Prairie MN
- Creating Word Documents by Using C# and XML Elk River MN
- Creating Word Documents by Using C# and XML Excelsior MN
- Creating Word Documents by Using C# and XML Faribault MN
- Creating Word Documents by Using C# and XML Fergus Falls MN
- Creating Word Documents by Using C# and XML Forest Lake MN
- Creating Word Documents by Using C# and XML Hastings MN
- Creating Word Documents by Using C# and XML Hibbing MN
- Creating Word Documents by Using C# and XML Hopkins MN
- Creating Word Documents by Using C# and XML Inver Grove Heights MN
- Creating Word Documents by Using C# and XML Lakeville MN
- Creating Word Documents by Using C# and XML Mankato MN
- Creating Word Documents by Using C# and XML Minneapolis MN
- Creating Word Documents by Using C# and XML Minnetonka MN
- Creating Word Documents by Using C# and XML Moorhead MN
- Creating Word Documents by Using C# and XML Mound MN
- Creating Word Documents by Using C# and XML New Ulm MN
- Creating Word Documents by Using C# and XML Osseo MN
- Creating Word Documents by Using C# and XML Owatonna MN
- Creating Word Documents by Using C# and XML Prior Lake MN
- Creating Word Documents by Using C# and XML Red Wing MN
- Creating Word Documents by Using C# and XML Rochester MN
- Creating Word Documents by Using C# and XML Rosemount MN
- Creating Word Documents by Using C# and XML Saint Cloud MN
- Creating Word Documents by Using C# and XML Saint Paul MN
- Creating Word Documents by Using C# and XML Savage MN
- Creating Word Documents by Using C# and XML Shakopee MN
- Creating Word Documents by Using C# and XML South Saint Paul MN
- Creating Word Documents by Using C# and XML Stillwater MN
- Creating Word Documents by Using C# and XML Wayzata MN
- Creating Word Documents by Using C# and XML Willmar MN
- Creating Word Documents by Using C# and XML Winona MN

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML