现根据grid 中的数据,导出一份文件(word),打印出来.

解决方案 »

  1.   


    <%@ page language="java" pageEncoding="gbk"%>  
    <%   
        String path = request.getContextPath();   
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";   
        response.setHeader("Content-disposition", "attachment; filename=word.doc");   
    %>  
      
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
    <html>  
        <head>  
            <base href="<%=basePath%>">  
      
            <title>My JSP 'word.jsp' starting page</title>  
      
            <meta http-equiv="pragma" content="no-cache">  
            <meta http-equiv="cache-control" content="no-cache">  
            <meta http-equiv="expires" content="0">  
            <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
            <meta http-equiv="description" content="This is my page">  
      
        </head>  
      
        <body>  
            第一页   
            <span lang=EN-US   
                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'> </span> 第二页   
        </body>  
    </html>  
    <%@ page language="java" pageEncoding="gbk"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    response.setHeader("Content-disposition", "attachment; filename=word.doc");
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <base href="<%=basePath%>"> <title>My JSP 'word.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page"> </head> <body>
    第一页
    <span lang=EN-US
    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'> </span> 第二页
    </body>
    </html> 
    你只需要把数据显示在这个页面就可以了
    就是说你点击导出的时候,传递一个参数到后台,然后返回这个页面。页面显示数据就是导出word的数据本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/IBM_hoojo/archive/2010/05/27/5628765.aspx