Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Description

Excerpt

Sets or returns the content-type header that will be sent to the browser with the generated Word document.

Signature
C#
C#
 public System.String ContentType{ get; set; }
Signature
vb.net
vb.net
Public Property ContentType() As String
Remarks

ContentType must not be used before Open is called, as the content-type of the file cannot be known until after the file is opened. Getting or setting ContentType before calling Open will throw an exception.

Example
Code Block
csharp
csharp
titleC#

          ...
          WordTemplate WordTempl = new WordTemplate();
          WordTempl.Open(Page.MapPath("./BasicTemplate.doc"));
          WordTempl.SetDataSource(MyDataTable);

          //--- Set the ContentType
          //--- ContentType is application/vns.ms-word by default for
          //--- .doc files, while the default ContentType for
          //--- .docx files is
          //--- application/vnd.openxmlformats-officedocument.wordprocessingml.document
          //--- and for .docm files is
          //--- application/vnd.ms-word.document.macroEnabled.12
          WordTempl.ContentType = "application/unknown";
          WordTempl.Process();
          WordTempl.Save(Page.Response, "BasicGenerated.doc", false);
          ...
        
Code Block
vb.net
vb.net
titlevb.net

          ...
          Dim WordTempl As New WordTemplate()
          WordTempl.Open(Page.MapPath("./BasicTemplate.doc"))
          WordTempl.SetDataSource(MyDataTable)

          '--- Set the ContentType
          '--- ContentType is application/vns.ms-word by default for
          '--- .doc files, while the default ContentType for
          '--- .docx files is
          '--- application/vnd.openxmlformats-officedocument.wordprocessingml.document
          '--- and for .docm files is
          '--- application/vnd.ms-word.document.macroEnabled.12
          WordTempl.ContentType = "application/unknown"
          WordTempl.Process()
          WordTempl.Save(Page.Response, "BasicGenerated.doc", False)
          ...