用html代码在word中插入分页符和页面设置
<span lang=EN-US style="font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:" mce_style="font-size:10.5pt;mso-bidi-font-size:12.0pt;font-family:"Times New Roman';mso-fareast-font-family:宋体;mso-font-kerning:1.0pt;mso-ansi- language EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all style="page-break-before:always" mce_style="page-break-before:always"></span>
最关键的是这段代码,它就是分页符:<br clear=all style="page-break-before:always" mce_style="page-break-before:always">
经常导出word功能,想在jsp、html中控制word的页数、在指定的位置进行分页可以通过这段代码进行分页。
今天在作转成Word时,遇到需要横向打印的问题,经研究可以通过设置样式表实现
首先在页面的head中加下面的一段代码
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:841.9pt 595.3pt;
mso-page-orientation:landscape;
margin:89.85pt 72.0pt 89.85pt 72.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
然后用div包含整个的显示内容,会调用上面的style
<div class=Section1>
</div>
下面是告诉IE是用Word打开此文件。
asp实现
<%
Response.AddHeader"content-Type","application/msword"
Response.AddHeader"content-Disposition","filename=机要文件一览表" &date()& ".doc;attachment;"
Response.Flush
%>
.net可以通过下面的代码实现
this.Page.Response.AddHeader("content-Type: ","application/msword);
this.Page.Response.AddHeader("Content-Disposition: ","attachment;filename="+name);