使用html將文字寫到word, 橫向, 換頁
Response.Clear()
Response.ContentType = "application/msword"
Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8
Response.Charset = "UTF-8"
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=abc.doc"))
Response.Write("<html>")
Response.Write("<head>")
Response.Write("<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=UTF-8'>")
Response.Write("<meta name=ProgId content=Word.Document>")
Response.Write("<meta name=Generator content='Microsoft Word 15'>")
Response.Write("<meta name=Originator content='Microsoft Word 15'>")
==橫向寫法==
Response.Write("<style>")
Response.Write("@page Section1 {size:841.9pt 595.3pt;font-family:細明體;mso-page-orientation:landscape;margin:57.65pt 42.55pt 57.65pt 1.0cm;mso-header-margin:1.0cm;mso-footer-margin:14.2pt;mso-paper-source:0;layout-grid:18.0pt;}")
Response.Write("div.Section1 {page:Section1;}")
Response.Write("</style>")
Response.Write("</head>")
Response.Write("<body>")
Response.Write("<div class=Section1>")
Response.Write(word的內容)
Response.Write("</div>")
Response.Write("</body>")
Response.Write("</html>")
Response.Flush()
Response.End()
換頁寫法:
"<span><br style='page-break-before:always'></span>"