private void download_character_certificate_word(string str_content_type, string memo_body, string school_id, string base_url) { StringBuilder str = new StringBuilder(); str.Append(memo_body); Response.Clear(); Response.ContentType = str_content_type; Response.Charset = ""; switch (str_content_type) { case "application/vnd.ms-excel": Response.AddHeader("Content-Disposition", "attachment; filename=Study_Certificate.xls;"); break; case "application/msword": Response.AddHeader("Content-Disposition", "attachment; filename=Study_Certificate.doc;"); break; default: break; } StringBuilder sbResponseString = new StringBuilder(); string wordHeader = "<html xmlns:o=''urn:schemas-microsoft-com:office:office'' "; wordHeader += "xmlns:w=''urn:schemas-microsoft-com:office:word'' "; wordHeader += "xmlns=''http://www.w3.org/TR/REC-html40''> "; wordHeader += "<head><title>Document Title</title>"; wordHeader += "<!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View><w:Zoom>100</w:Zoom>"; wordHeader += "<w:DoNotOptimizeForBrowser/></w:WordDocument></xml><![endif]-->"; wordHeader += "<style> @page Section1 {size:8.2in 11.6in; mso-first-footer:ff1; mso-footer: f1; mso-header: h1; "; wordHeader += " padding:2.0pt 1.5pt 1.5pt 1.5pt; border:0pt;"; wordHeader += "margin:1.0in 0.8in 1.0in 0.8in ; mso-header-margin:0.1in; "; wordHeader += "mso-footer-margin:0.1in; mso-paper-source:0;} "; wordHeader += "div.Section1 {page:Section1;} p.MsoFooter, li.MsoFooter, "; wordHeader += "div.MsoFooter{margin:0in; margin-bottom:0pt; "; wordHeader += "mso-pagination:widow-orphan; tab-stops:center 1.0in right 1.0in; "; wordHeader += "font-size:9.0pt; font-family:'Arial';} "; wordHeader += "p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; "; wordHeader += "margin-bottom:0pt; mso-pagination:widow-orphan; tab-stops:center "; wordHeader += "0.2in right 0.2in; font-size:8.0pt; font-family:'TimesNewRoman';}--></style></head>"; string wordBody = "<body><div class=Section1>" + str.ToString() + "</div></body></html>";// sbResponseString.Append(wordHeader); sbResponseString.Append(wordBody); Response.Write(sbResponseString.ToString()); Response.End(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)