e股脑电脑教程网
  • 首 页
  • 操作系统
  • 应用软件
  • 下载工具
  • 影音视频
  • 办公软件
  • 媒体制作
  • 网站建设
  • 平面设计
  • 数据库
  • 程序开发
  • 视频教程
编辑推荐: | 文章搜索:
您现在的位置: e股脑 >> 程序开发 >> JSP教程 >> 把本页内容导出成word文件或excel文件(原创) >> 教程正文
 
教程搜索
 
 
相关教程
  • JSP分页技术实现
  • 使用XML封装数据库操作语句的实现(完
  • 结合”XML封装数据库操作语句的实现”
  • 如何使用XML实现多渠道接入网站的构架
  • 深入浅出taglib
  • 在JSP中编写你的第一个Tag
  • 用Java实现Web服务器
  • 如何利用xml,javascript绕开apple
  • 缓存JSP显示的内容
  • 关于JAVA的分页查询操作技术
  • 漫步j2ee之jsp技术(1)
  • 漫步j2ee之jsp技术(2)
  • Portlet应用开发(Portlet Specs v1.0)
  • 如何用jsp输出存在于oracle数据库Blob
  • Servlet设计
  • 用servlet显示图片
 
 

图文教程


  • Windows抢了谁的饭碗 非主流操作系统To

  • 地球还是火星 平常心看“非主流”

  • 综合运用Office 2007批量制作奖状

  • 没有系统盘如何才能修复受损系统?

  • 巧妙运用Excel中边界的附加功能!
 
 
赞 助 商
 
 
把本页内容导出成word文件或excel文件(原创)
  • 来源:e股脑
  • 点击次数:
  • 更新时间:2007-8-9

说明:文件unload.js在js目录下,文件unload_excel.jsp和unload_word.jsp在unload目录下。

1,unload.js

/**************************************************

作者:云凤生(hainanyun@hotmail.com)

创建日期:2005-1-21

最后修改日期:2005-3-30

Function:

1,unload_word():unload local page as word file

2,unload_excel():unload local page as excel file

3,...(waiting for your additional work)

For example:

1,in the head of HTML file,include this file:

<script src="http://www.chinaitpower.com/A200508/2005-08-10/js/unload.js" type="text/javascript"></script>

2,add unload button:

<input type="button" value="导出为Word文档" name="download" onclick="unload_word(location.href)" >

<input type="button" value="导出为Excel文档" name="download" onclick="unload_excel(location.href)" >

**************************************************/

function unload_word()

{

var url=location.href;

location.href="http://www.chinaitpower.com/A200508/2005-08-10/unload/unload_word.jsp?url=+url;}

function unload_excel()

{

var url=location.href;

location.href="http://www.chinaitpower.com/A200508/2005-08-10/unload/unload_excel.jsp?url=+url;}

2,unload_excel.jsp

<%

response.setHeader("Content-disposition","attachment; filename=print_tmp.xls");

%>

<%@ page contentType="application/vnd.ms-excel; charset=gb2312"%>

<%@ page import="java.net.URL"%>


<meta http-equiv="Content-Language" content="zh-cn">

<meta name="GENERATOR" content="Microsoft FrontPage 5.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<%

String url_target = new String(request.getParameter("url"));

String filename = new String();

URL url = new URL(url_target);

filename = url.getFile();

%>

<jsp:include page="<%=filename%>" />

3,unload_word.jsp

<%

response.setHeader("Content-disposition","attachment; filename=print_tmp.doc");

%>

<%@ page contentType="application/vnd.ms-word; charset=gb2312"%>

<%@ page import="java.net.URL"%>

<meta http-equiv="Content-Language" content="zh-cn">

<meta name="GENERATOR" content="Microsoft FrontPage 5.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<%

String url_target = new String(request.getParameter("url"));

String filename = new String();

URL url = new URL(url_target);

filename = url.getFile();

%>

<jsp:include page="<%=filename%>" />


  • 上一篇教程: 在BEA WebLogic中使用Java消息服务
  • 下一篇教程: BEA WebLogic Workshop 8.1&#8482; 与Microsoft&reg; Visual Studio.NET 1.1 Web Services的互操作性研究
  •  

    关于本站 | 广告联系 | 版权声明 | 使用帮助

    Copyright © 2004-2008 www.egunao.com All rights reserved.