Wiki Markup |
---|
{description} {excerpt}Sets or returns the content\-type header that will be sent to the browser with the generated Word document. {excerpt} {signature:C#} public System.String ContentType{ get; set; } {signature} {signature:vb.net} Public Property ContentType() As String {signature} {remarks}ContentType must not be used before [Open|WordTemplate.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. {remarks} {example}{code:csharp|title=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); ... {code} {code:vb.net|title=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) ... {code} {example} |
Page History
Overview
Content Tools