Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
void Save(Document doc,
	bool preserve,
	String fileName)

If preserve is true, WordWriter will try to preserve all formatting and features in the file, including those that it does not directly support. These includes fields, footnotes, hyperlinks, comments, and anchored images. If preserve is false, only features directly supported by WordWriter will be preserved. These includes all tables, lists, headers, and footers. Setting preserve to false will produce a much smaller file.

fileName specifies a complete physical path and file name for the generated file. WordWriter will save the file to this location. If a file with the same name exists, it will be overwritten by the new Word file.

...

Code Block
c#
c#
WordApplication wwapp = new WordApplication();
Document doc = wwapp.Create();
wwapp.Save(doc, false, @"C:\Sales2003\June.doc");

...

Code Block
void Save(Document doc,
     bool preserve,
     System.Web.HttpResponse response,
     String fileName,
     bool openInBrowser)

void Save(Document doc,
     bool preserve,
     System.Web.HttpResponse response,
     String fileName,
     bool openInBrowser,
     String contentType)

If preserve is true, WordWriter will try to preserve all formatting and features in the file, including those that it does not directly support. These includes fields, footnotes, hyperlinks, comments, and anchored images. If preserve is false, only features directly supported by WordWriter will be preserved. These includes all tables, lists, headers, and footers. Setting preserve to false will produce a much smaller file.

fileName specifies a complete physical path and file name for the generated file. WordWriter will save the file to this location. If a file with the same name exists, it will be overwritten by the new Word file.

...

Internet Explorer can display a Word file in the browser window. When the generated document is streamed to Internet Explorer, the browser's settings will determine whether the file opens automatically or the user is asked to open or save the file. The parameter openInBrowserdetermines whether the file will open in IE or in a document application. If openInBrowser is set to true, the response content-disposition header is set to open the file in the browser window.

Note

The ability to load Word files directly in Internet Explorer is disabled by default in IE 8 and higher.

Example

Code Block
c#
c#
WordApplication wwapp = new WordApplication();
Document doc = wwapp.Create();
wwapp.Save(doc,
     false,
     Page.Response,
     "file.doc",
     true,
     "application/vnd.ms-word");

Anchor
stream
stream

Write to Stream

...

Code Block
void Save(Document doc,
     bool preserve,
     OutputStream out)

If preserve is true, WordWriter will try to preserve all formatting and features in the file, including those that it does not directly support. These includes fields, footnotes, hyperlinks, comments, and anchored images. If preserve is false, only features directly supported by WordWriter will be preserved. These includes all tables, lists, headers, and footers. Setting preserve to false will produce a much smaller file.

Example

Code Block
c#
c#
WordApplication wwapp = new WordApplication();
Document doc = wwapp.Create();
System.IO.Stream fstream = new System.IO.FileStream (@"C:\file.doc", FileMode.Create);
wwapp.Save(doc, false, fstream);

Anchor
template
template

...