欢迎光临
我们一直在努力

jsp操作Execl分析-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

<%@ page contenttype="text/html; charset=gb2312" language="java" import="java.sql.*" %>

<%@ page import="jxl.*"%>

<%@ page import="jxl.write.*"%>

<%@ page import="java.io.*"%>

<%@ page import="java.util.*"%>

<jsp:usebean id="conn" class="db.dbconnection" scope="page"/>

<%

string sql=(string)session.getvalue("sql");

//string apti=(string)session.getvalue("apti");

//select companyapti.companyid,companyapti.companytype,companyapti.c

ompanyname,companyinfo.province,companyinfo.city, companyinfo.address,

//companyinfo.connectman,companyinfo.mobile,companyinfo.tel,companyinfo.telephone

%>

<%

try{

writableworkbook workbook = workbook.createworkbook(new file(request.getrealpath("/")+"/mis/"+"/企业信息.xls"));

//创建excel工作表

writablesheet sheet=workbook.createsheet("企业信息",0);

//jxl.write.writablesheet ws = wwb.createsheet("test sheet 1", 0);

//设置字体和格式

//writer data

//while (rs.next()) { //while start

// for(int i=1;i<=23;i++){

// username=rs.getstring(1).equals("0")?"":rs.getstring(1).trim();

// username="yzhxy2002";

// label l=new label(0, 0, username );

// sheet.addcell(l);

//jxl.write.label labelc = new jxl.write.label(1, 0, "this is a label cell");

//sheet.addcell(labelc);

label n=null,p=null,c=null,a=null,m=null,s=null,t=null,t1=null,t2=null;

string companyid="", apti="",aptiname="",companyname="",companytype="",province="",

city="",address="",connectman="",mobile="",tel="",telephone="";

resultset rs=null;

//out.print(sql);

rs=conn.executequery(sql);

int i=0;

while(rs.next()){

//查询资质

stringtokenizer fenxi=new stringtokenizer(rs.getstring("companytype"),"-");

while(fenxi.hasmoretokens()){

companytype=fenxi.nexttoken().tostring();

string sql0="select * from aptitype where typeid="+companytype+"";

resultset rs0=conn.executequery(sql0);

if(rs0.next()){

aptiname=new string(rs0.getstring("typename").getbytes("iso8859-1") );

}

apti=aptiname+"-"+apti;

}//while

//

n=new label(0,i,new string(rs.getstring("companyname").getbytes("iso8859-1")));

p=new label(1,i,new string(rs.getstring("province").getbytes("iso8859-1")));

c=new label(2,i,new string(rs.getstring("city").getbytes("iso8859-1")));

a=new label(3,i,new string(rs.getstring("address").getbytes("iso8859-1")));

m=new label(4,i,new string(rs.getstring("connectman").getbytes("iso8859-1")));

s=new label(5,i,rs.getstring("mobile"));

t=new label(6,i,rs.getstring("tel"));

t1=new label(7,i,rs.getstring("telephone"));

t2=new label(8,i,apti);

sheet.addcell(n);sheet.addcell(p);sheet.addcell(c);

sheet.addcell(a);sheet.addcell(m);sheet.addcell(s);sheet.addcell(t);sheet.addcell(t1);

sheet.addcell(t2);

i++;

apti="";

}

//out.print(rs.get(0,2));

//第二个表

// writablesheet sheet1=workbook.createsheet("资质信息",1);

//companytype

workbook.write();

workbook.close();

// }

// }//while end

}

catch (exception e)

{

e.printstacktrace();

}

%>

<html>

<head>

<title>操作excel表</title>

</head>

<body>

<table width="653" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td>&nbsp;</td>

</tr>

<tr>

<td>&nbsp;</td>

</tr>

<tr>

<td height="46"><div align="center"><a href="企业信息.xls">

<img src="../images/ziguang.gif" width="32" height="32" border="0">下载企业信息</a></div></td>

</tr>

<tr>

<td><br>

</td>

</tr>

<tr>

<td>&nbsp;</td>

</tr>

</table>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » jsp操作Execl分析-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章