我尝试使用以下代码生成word文档:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;
filename=" + DateTime.Now + ".doc");
var strHTMLContent = new StringBuilder();
strHTMLContent.Append(
"
Document Heading
");strHTMLContent.Append("
");
strHTMLContent.Append("
// Row with Column headers
strHTMLContent.Append("
");strHTMLContent.Append("
Column1
");strHTMLContent.Append("
Column2
");strHTMLContent.Append("
Column 3
");strHTMLContent.Append("
");// First Row Data
strHTMLContent.Append("
");strHTMLContent.Append(
"
");strHTMLContent.Append(
"
b");strHTMLContent.Append(
"
c");strHTMLContent.Append("
");// Second Row Data
strHTMLContent.Append("
");strHTMLContent.Append(
"
d");strHTMLContent.Append(
"
e");strHTMLContent.Append(
"
f");strHTMLContent.Append("
");strHTMLContent.Append("
");strHTMLContent.Append("
");
strHTMLContent.Append(
"
Note : This is a dynamically
generated word document
");HttpContext.Current.Response.Write(strHTMLContent);
// HttpContext.Current.Response.BinaryWrite(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
它工作正常,但我想使它成为横向,并在打印布局中导致它出现在Web布局中
有谁能够帮我?