Page tree
    Created with Raphaël 2.1.0
    Loading...
Skip to end of metadata
Go to start of metadata

Description

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

C#
public System.String ContentType{ get; set; }
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.

Examples

C#
...
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);
...
vb.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)
...
  • No labels