近日做项目遇到一些问题搞不定,先贴代码:
StringBuilder strBody = new StringBuilder(); strBody.Append("<html " +
"xmlns:o='urn:schemas-microsoft-com:office:office' " +
"xmlns:w='urn:schemas-microsoft-com:office:word'" +
"xmlns='http://www.w3.org/TR/REC-html40'>" +
"<head><title>Time</title>");
//'The setting specifies document's view after it is downloaded as Print
//'instead of the default Web Layout
strBody.Append("<!--[if gte mso 9]>" +
"<xml>" +
"<w:WordDocument>" +
"<w:View>"+this.DropDownList1.SelectedValue +"</w:View>" +
"<w:Zoom>100</w:Zoom>" +
"<w:DoNotOptimizeForBrowser/>" +
"</w:WordDocument>" +
"</xml>" +
"<![endif]-->"); strBody.Append("<style>" +
"<!-- /* Style Definitions */" +
"@page Section1" +
" {size:8.5in 11.0in; " +
" margin:1.0in 1.25in 1.0in 1.25in ; " +
" mso-header-margin:.5in; mso-page-orientation:portrait;" +
" mso-footer-margin:.5in; mso-paper-source:0;}" +
" div.Section1" +
" {page:Section1;}" +
"-->" +
"@page Section2" +
" {size:12.5in 11.0in; " +
" margin:1.0in 1.25in 1.0in 1.25in ; " +
" mso-header-margin:.5in; mso-page-orientation:landscape;" +
" mso-footer-margin:.5in; mso-paper-source:0;}" +
" div.Section2" +
" {page:Section2;}" +
"-->" +
"</style></head>"); strBody.Append("<body lang=EN-US style='tab-interval:.5in'>" +
"<div class=Section1>" +
"something before cost item <br clear=all style='page-break-before:always'>" +
"<div class=Section"+this.DropDownList2.SelectedValue +">" +
"before"+
this.FreeTextBox1.Text + " <br clear=all style='page-break-before:always'>"+ "</div> other content to export</div></body></html>");
//'Force this content to be downloaded
//'as a Word document with the name of your choice
Response.AppendHeader("Content-Type", "application/msword");
Response.AppendHeader("Content-disposition", "attachment; filename=myword.doc");
Response.Write(strBody);
Response.End();
我想让蓝色部分的内容用横版(landscape)来排列,而其他部分,比如红色部分用竖版(portrait)。因为蓝色部分用竖版是显示不全的,但现在的问题是:用上面的代码貌似全部都是横版排列了,并不是我想要的结果,大家对此有什么好的意见啊,敬请指点。
StringBuilder strBody = new StringBuilder(); strBody.Append("<html " +
"xmlns:o='urn:schemas-microsoft-com:office:office' " +
"xmlns:w='urn:schemas-microsoft-com:office:word'" +
"xmlns='http://www.w3.org/TR/REC-html40'>" +
"<head><title>Time</title>");
//'The setting specifies document's view after it is downloaded as Print
//'instead of the default Web Layout
strBody.Append("<!--[if gte mso 9]>" +
"<xml>" +
"<w:WordDocument>" +
"<w:View>"+this.DropDownList1.SelectedValue +"</w:View>" +
"<w:Zoom>100</w:Zoom>" +
"<w:DoNotOptimizeForBrowser/>" +
"</w:WordDocument>" +
"</xml>" +
"<![endif]-->"); strBody.Append("<style>" +
"<!-- /* Style Definitions */" +
"@page Section1" +
" {size:8.5in 11.0in; " +
" margin:1.0in 1.25in 1.0in 1.25in ; " +
" mso-header-margin:.5in; mso-page-orientation:portrait;" +
" mso-footer-margin:.5in; mso-paper-source:0;}" +
" div.Section1" +
" {page:Section1;}" +
"-->" +
"@page Section2" +
" {size:12.5in 11.0in; " +
" margin:1.0in 1.25in 1.0in 1.25in ; " +
" mso-header-margin:.5in; mso-page-orientation:landscape;" +
" mso-footer-margin:.5in; mso-paper-source:0;}" +
" div.Section2" +
" {page:Section2;}" +
"-->" +
"</style></head>"); strBody.Append("<body lang=EN-US style='tab-interval:.5in'>" +
"<div class=Section1>" +
"something before cost item <br clear=all style='page-break-before:always'>" +
"<div class=Section"+this.DropDownList2.SelectedValue +">" +
"before"+
this.FreeTextBox1.Text + " <br clear=all style='page-break-before:always'>"+ "</div> other content to export</div></body></html>");
//'Force this content to be downloaded
//'as a Word document with the name of your choice
Response.AppendHeader("Content-Type", "application/msword");
Response.AppendHeader("Content-disposition", "attachment; filename=myword.doc");
Response.Write(strBody);
Response.End();
我想让蓝色部分的内容用横版(landscape)来排列,而其他部分,比如红色部分用竖版(portrait)。因为蓝色部分用竖版是显示不全的,但现在的问题是:用上面的代码貌似全部都是横版排列了,并不是我想要的结果,大家对此有什么好的意见啊,敬请指点。
this.DropDownList2.SelectedValue =2