Message-ID: <2105548771.8433.1711646140410.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8432_190123980.1711646140410" ------=_Part_8432_190123980.1711646140410 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Table of Contents |
---|
=20
|
After creating a document with WordApplication, you can:
To save the generated file on the server, call:
void Save(Document doc, =09String fileName)=20
fileName specifies a complete physical path and file name for the genera= ted file. WordWriter will save the file to this location. If a file with th= e same name exists, it will be overwritten by the new Word file.
Example
WordApplication wwapp =3D new WordApplication(); Document doc =3D wwapp.Create(); wwapp.Save(doc, @"C:\Sales2003\June.doc");=20
To stream the generated file to the client, call one of the following me= thods:
void Save(Document doc, System.Web.HttpResponse response, String fileName, bool openInBrowser) void Save(Document doc, System.Web.HttpResponse response, String fileName, bool openInBrowser)=20
fileName specifies a complete physical path and file name for the genera= ted file. WordWriter will save the file to this location. If a file with th= e same name exists, it will be overwritten by the new Word file.
Browsers other than Internet Explorer cannot embed a Word file in the br= owser window. When the generated document is streamed to a browser other th= an IE, the user will always be prompted to open or save the file. If the us= er chooses to open the file, it will open in Microsoft Word or another docu= ment application.
Internet Explorer can display a Word file in the browser window. When th= e generated document is streamed to Internet Explorer, the browser's settin= gs will determine whether the file opens automatically or the user is asked= to open or save the file. The parameter openInBrowserdetermines whether th= e file will open in IE or in a document application. If openInBrowser is se= t to true, the response content-disposition header is set to open the file = in the browser window.
=20 =20 =20Example
WordApplication wwapp =3D new WordApplication(); Document doc =3D wwapp.Create(); wwapp.Save(doc, Page.Response, "file.doc", true);=20
To write the generated document to a System.IO.Stream, call:
void Save(Document doc, OutputStream out)=20
Example
WordApplication wwapp =3D new WordApplication(); Document doc =3D wwapp.Create(); System.IO.Stream fstream =3D new System.IO.FileStream (@"C:\file.doc&q= uot;, FileMode.Create); wwapp.Save(doc, fstream);=20
You can use WordApplication to create a document with merge fields (i.e.= , a template) and pass the file to WordTemplate to populate the merge field= s. To pass a document to WordTemplate, use the following method:
WordTemplate.Open(WordApplication aApp, Document aDoc)=20
Example
WordApplication wwApp =3D new WordApplication(); Document doc =3D wwApp.Create(); WordTemplate wwTmpl =3D New WordTemplate(); wwTmpl.Open(wwApp, doc);=20