| 发表于:2008-01-23 10:44:58 楼主 |
在servlet/jsp里,如何设置以文本格式导出生成EXECl表格? public void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { request.setcharacterencoding("gbk"); response.setcontenttype("application/vnd.ms-excel;charset=gbk"); printwriter out=response.getwriter(); daofactory cloudscapefactory = daofactory.getdaofactory(daofactory.mssql); customerdao custdao = cloudscapefactory.getcustomerdao(); set set=null; outscan outscan=null; string o_time= request.getparameter("o_time");//取值 response.setheader("content-disposition","attachment; filename="+o_time +".xls"); set=custdao.selectotime(o_time); iterator it = set.iterator(); request.setcharacterencoding("gbk"); out.println("出货单号\t出货时间\t出货人\t包装箱序列号\t产品序列号"); while (it.hasnext()) { outscan = (outscan) it.next(); // string filename = new string(outscan.geto_people().getbytes("iso8859_1"), "gbk"); //把outscan.geto_no()的值,导出成EXECl表时以 文本格式 显示? 请高手帮忙看看,有代码的直接帮我加上是最好了,谢谢了! out.println(""+outscan.geto_po()+"\t"+outscan.geto_time()+"\t"+outscan.geto_people()+"\t"+outscan.geto_cartowtd()+"\t"+outscan.geto_no()); request.getsession().setattribute("id",outscan.geto_time()); } out.flush(); out.close(); } |
|
|
|
|