主题:急!急!请求高手帮忙!
我是一初学者,最近做了个信息管理系统,用的是resin+oracle9i,现在遇到了一个问题,如何将查询到的信息导入到EXCEL表中,或者直接打印。我从网上也看了好多相关材料,但不知如何下手,请高手指定一二。以上是我的查询页面的源代码,导出和打印该怎么写呢?请帮帮忙吧!(我的邮箱:xzw_cn@163.com)
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.io.*,java.text.*,java.util.Date,java.util.*,java.math.*,java.sql.*,java.net.*,java.lang.*,comm.*"%>
<%! String strSQL="",fwSQL="",searchcontent1,searchfanwei,searchcontent; %>
<html>
<head>
<link rel="stylesheet" href="public.css">
</head>
<body>
<br>
<center>
<form name="form1" method="POST" action="prinout.jsp">
<table border="0" width="95%">
<tr><FONT color=#ffffff><B> 查询结果</FONT></b>
<% try{
// 取得查询关键则
searchcontent1 = request.getParameter("searchcontent");
searchcontent = "%" + searchcontent1 + "%";
// 取得查询字段值
searchfanwei = request.getParameter("D1");
if(searchfanwei.equals("qysh"))
strSQL = " qysh like'"+searchcontent+"' order by qysh desc";
else if(searchfanwei.equals("qyname"))
strSQL =" qyname like'"+searchcontent+"' order by qysh desc";
strSQL = " where " + strSQL;
// 定义数组对象接受查询的记录信息
ArrayList schList = new ArrayList();
// 定义字符串数组
String sInfo[] = new String[4];
QYinfo o_Info = new QYinfo();
schList = o_Info.getSearchResult(strSQL);
int iQyCnt=schList.size();
if(schList.size()==0)
out.println("<td align=center colspan=9><font color=red>未能找到,请重新查询!</font></td>");
else
{ out.println("<td align=center><font color=red>总"+iQyCnt+"条</font></td>");%>
<table width=98% align="center" cellspacing=1 cellpadding=2 border=1 bordercolor=#808080 bordercolordark=#FFFFFF style=font-size: 9pt; font-family: 宋体 bordercolorlight=#DAC1E1>
<br><tr>
<td align=center width=6% bgcolor=#C9E9FA>序号</td>
<td align=center width=30% bgcolor=#C9E9FA>企业名称</td>
<td align=center width=12% bgcolor=#C9E9FA>企业税号</td>
<td align=center width=30% bgcolor=#C9E9FA>企业地址</td>
<td align=center width=12% bgcolor=#C9E9FA>联系电话</td>
<td align=center width=10% bgcolor=#C9E9FA>联系人</td>
</tr>
<% for(int j=0;j<schList.size();j++)
{
sInfo = (String[])schList.get(j);
out.println("<td align=middle><font color=blue>"+(j+1)+"</font></td>");
out.println("<td align=left><font size=2>"+sInfo[0]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[1]+"</td>");
out.println("<td align=left><font size=2>"+sInfo[2]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[3]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[4]+"</td></tr>");
}
}
}
catch(Exception e)
{throw new Exception(e.getMessage());}
%>
</td></tr>
</table>
<p><p><input type="submit" value=" 导出 " name="daochu">
<input type="submit" value=" 打印预览 " name="dyyl">
<input type="submit" value=" 打印 " name="dayin">
</center>
</body>
</html>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.io.*,java.text.*,java.util.Date,java.util.*,java.math.*,java.sql.*,java.net.*,java.lang.*,comm.*"%>
<%! String strSQL="",fwSQL="",searchcontent1,searchfanwei,searchcontent; %>
<html>
<head>
<link rel="stylesheet" href="public.css">
</head>
<body>
<br>
<center>
<form name="form1" method="POST" action="prinout.jsp">
<table border="0" width="95%">
<tr><FONT color=#ffffff><B> 查询结果</FONT></b>
<% try{
// 取得查询关键则
searchcontent1 = request.getParameter("searchcontent");
searchcontent = "%" + searchcontent1 + "%";
// 取得查询字段值
searchfanwei = request.getParameter("D1");
if(searchfanwei.equals("qysh"))
strSQL = " qysh like'"+searchcontent+"' order by qysh desc";
else if(searchfanwei.equals("qyname"))
strSQL =" qyname like'"+searchcontent+"' order by qysh desc";
strSQL = " where " + strSQL;
// 定义数组对象接受查询的记录信息
ArrayList schList = new ArrayList();
// 定义字符串数组
String sInfo[] = new String[4];
QYinfo o_Info = new QYinfo();
schList = o_Info.getSearchResult(strSQL);
int iQyCnt=schList.size();
if(schList.size()==0)
out.println("<td align=center colspan=9><font color=red>未能找到,请重新查询!</font></td>");
else
{ out.println("<td align=center><font color=red>总"+iQyCnt+"条</font></td>");%>
<table width=98% align="center" cellspacing=1 cellpadding=2 border=1 bordercolor=#808080 bordercolordark=#FFFFFF style=font-size: 9pt; font-family: 宋体 bordercolorlight=#DAC1E1>
<br><tr>
<td align=center width=6% bgcolor=#C9E9FA>序号</td>
<td align=center width=30% bgcolor=#C9E9FA>企业名称</td>
<td align=center width=12% bgcolor=#C9E9FA>企业税号</td>
<td align=center width=30% bgcolor=#C9E9FA>企业地址</td>
<td align=center width=12% bgcolor=#C9E9FA>联系电话</td>
<td align=center width=10% bgcolor=#C9E9FA>联系人</td>
</tr>
<% for(int j=0;j<schList.size();j++)
{
sInfo = (String[])schList.get(j);
out.println("<td align=middle><font color=blue>"+(j+1)+"</font></td>");
out.println("<td align=left><font size=2>"+sInfo[0]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[1]+"</td>");
out.println("<td align=left><font size=2>"+sInfo[2]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[3]+"</td>");
out.println("<td align=middle><font size=2>"+sInfo[4]+"</td></tr>");
}
}
}
catch(Exception e)
{throw new Exception(e.getMessage());}
%>
</td></tr>
</table>
<p><p><input type="submit" value=" 导出 " name="daochu">
<input type="submit" value=" 打印预览 " name="dyyl">
<input type="submit" value=" 打印 " name="dayin">
</center>
</body>
</html>