• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
《储备驿站》



                           淡泊以明志,宁静而志远!
博客园    首页    新随笔    联系   管理    订阅  订阅
页面导成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
  %
>

<% 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); 
posted on 2005-11-19 15:16  Dansin  阅读(1798)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3