高分在线求助:如何将以下网页上的内容(Shipper = DAIMLERCHRYSLER CORP)通过点击"SAVE"按钮打开保存对话框并存为Excel文件??? 你可以用APACHE上的POI接口包完成该功能。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://jakarta.apache.org/poi/index.html sidshen(阿布) :如何保存为word(.doc)格式?? 只要把contentType改成application/msword就可以了具体实现这样,用表单提交个action参数到后面的页面,后面页面判断action,如果是要打印,就response.setContentType("application/msword");这样,当前页面就成了word文档了 sidshen(阿布) :还是不明白,能不能结合我给的实例说明一下>谢谢 说明:print_head目录中为要打印内容。传递两个参数type和printtype控制显示的内容是什么格式,如果type="word",那么就把文档的格式改为word格式,否则是text/html,print控制显示什么内容<%@ page contentType="text/html; charset=GBK" %><%@ page language="java" import="java.sql.*" %><%@ page import="java.util.*" %><%@ include file="include/beans.jsp"%><%@ include file="include/chk.jsp"%><%String print=request.getParameter("print");String type=request.getParameter("type");if("word".equals(type)) response.setContentType("application/msword");String isNone=null;String yanzheng_month=request.getParameter("yanzheng_month");int aa=0;int cc=0;String yanche_month=request.getParameter("yanche_month");int bb=0;String sql=null;ResultSet rs=null;if(print.equals("driver_all")){%><%@ include file="print_head/driver_all.inc"%><%}if(print.equals("driver_yanzheng")){ if(yanzheng_month.equals("")||yanzheng_month==null) out.print("传入参数不正确!"); else{ aa=Integer.parseInt(yanzheng_month);%><%@ include file="print_head/driver_yanzheng.inc"%><%}}if(print.equals("car_all")){%><%@ include file="print_head/car_all.inc"%><%}if(print.equals("car_yanche")){ if(yanche_month.equals("")||yanche_month==null) out.print("传入参数不正确!"); else{ bb=Integer.parseInt(yanche_month);%> <%@ include file="print_head/car_yanche.inc"%><% }}if(print.equals("repair_all")){%> <%@ include file="print_head/repair_all.inc"%><%}if(print.equals("accident_all")){%> <%@ include file="print_head/accident_all.inc"%><%}%> 把你的方法结合我下面的网页<html><head><title>save</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body bgColor=#FFFFFF text="#996666"><FORM name=clock action="" method=""><table width="50%" border="1" align="center" cellspacing="0" bordercolor="#3399FF" cellpadding="0"> <tr> <td> <table width="100%" border="0" bordercolor="#33FFFF"> <td> <table width="100%" border="0"> <tr> <td width="52%" height="19"> <div align="right">Shipper =</div> </td> <td width="48%" height="19">DAIMLERCHRYSLER CORP</td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <table width="100%" border="0"> <tr> <td width="47%"> </td> <td width="53%"> <input type="submit" name="Submit" value="SAVE"> </td> </tr> </table> </td> </tr> </table> </td> </tr></table></FORM></body></html> 这样只要一点save就会把当前页面转换为word格式<%@ page contentType="text/html; charset=GBK" %><%String type=request.getParameter("type");if("word".equals(type)) response.setContentType("application/msword");%><html><head><title>save</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body bgColor=#FFFFFF text="#996666"><FORM name=clock action="?type=word" method="get"><table width="50%" border="1" align="center" cellspacing="0" bordercolor="#3399FF" cellpadding="0"> <tr> <td> <table width="100%" border="0" bordercolor="#33FFFF"> <td> <table width="100%" border="0"> <tr> <td width="52%" height="19"> <div align="right">Shipper =</div> </td> <td width="48%" height="19">DAIMLERCHRYSLER CORP</td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <table width="100%" border="0"> <tr> <td width="47%"> </td> <td width="53%"> <input type="submit" name="Submit" value="SAVE"> </td> </tr> </table> </td> </tr> </table> </td> </tr></table></FORM></body></html> 一个地方改错了,你把form的method改为post就好了 不对!一没有保存文件对话框,二也根本没有实质的反映(没有产生.doc文件),只是IE地址栏多了一个什么"type=word".:( 程序在我这里运行就可以打印,要不你把<meta http-equiv="Content-Type" content="text/html; charset=gb2312">这一行去掉 你访问一下这个页面http://61.170.213.29:8080/sssc/print.jsp java 连接mysql js 的Tree放入数据库数据 Eclipse开发JSP问题 iframe中如何得到父窗的变量 求助一个困扰了我好几天得问题! 请问大家如何在圆内产生一个随机点? 困扰我很久的问题 怎样配置Servlet? 一个jsp的小问题 DW MX不能设置站点了,怎么办?555 菜鸟问题 最后的问题,我的这个BEAN能在一个JSP中使用,但另一个JSP中就连import netoffice.*(BEAN所在包)都出错,说找不到此包,非常不解。
具体实现这样,用表单提交个action参数到后面的页面,后面页面判断action,如果是要打印,就response.setContentType("application/msword");
这样,当前页面就成了word文档了
print_head目录中为要打印内容。传递两个参数type和print
type控制显示的内容是什么格式,如果type="word",那么就把文档的格式改为word格式,否则是text/html,print控制显示什么内容<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ include file="include/beans.jsp"%>
<%@ include file="include/chk.jsp"%>
<%String print=request.getParameter("print");
String type=request.getParameter("type");
if("word".equals(type))
response.setContentType("application/msword");
String isNone=null;
String yanzheng_month=request.getParameter("yanzheng_month");
int aa=0;
int cc=0;
String yanche_month=request.getParameter("yanche_month");
int bb=0;
String sql=null;
ResultSet rs=null;
if(print.equals("driver_all")){
%>
<%@ include file="print_head/driver_all.inc"%>
<%
}
if(print.equals("driver_yanzheng")){
if(yanzheng_month.equals("")||yanzheng_month==null)
out.print("传入参数不正确!");
else{
aa=Integer.parseInt(yanzheng_month);
%>
<%@ include file="print_head/driver_yanzheng.inc"%>
<%
}}
if(print.equals("car_all")){
%>
<%@ include file="print_head/car_all.inc"%>
<%}
if(print.equals("car_yanche")){
if(yanche_month.equals("")||yanche_month==null)
out.print("传入参数不正确!");
else{
bb=Integer.parseInt(yanche_month);
%>
<%@ include file="print_head/car_yanche.inc"%>
<%
}
}if(print.equals("repair_all")){
%>
<%@ include file="print_head/repair_all.inc"%>
<%
}
if(print.equals("accident_all")){
%>
<%@ include file="print_head/accident_all.inc"%>
<%
}
%>
<head>
<title>save</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgColor=#FFFFFF text="#996666">
<FORM name=clock action="" method=""><table width="50%" border="1" align="center" cellspacing="0" bordercolor="#3399FF" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" bordercolor="#33FFFF">
<td>
<table width="100%" border="0">
<tr>
<td width="52%" height="19">
<div align="right">Shipper =</div>
</td>
<td width="48%" height="19">DAIMLERCHRYSLER CORP</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0">
<tr>
<td width="47%"> </td>
<td width="53%">
<input type="submit" name="Submit" value="SAVE">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</FORM>
</body>
</html>
<%@ page contentType="text/html; charset=GBK" %>
<%
String type=request.getParameter("type");
if("word".equals(type))
response.setContentType("application/msword");
%>
<html>
<head>
<title>save</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgColor=#FFFFFF text="#996666">
<FORM name=clock action="?type=word" method="get"><table width="50%" border="1" align="center" cellspacing="0" bordercolor="#3399FF" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" bordercolor="#33FFFF">
<td>
<table width="100%" border="0">
<tr>
<td width="52%" height="19">
<div align="right">Shipper =</div>
</td>
<td width="48%" height="19">DAIMLERCHRYSLER CORP</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0">
<tr>
<td width="47%"> </td>
<td width="53%">
<input type="submit" name="Submit" value="SAVE">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</FORM>
</body>
</html>
这一行去掉
http://61.170.213.29:8080/sssc/print.jsp