在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();
}
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();
}
request.setCharacterEncoding("GBK");
response.setContentType("application/vnd.ms-excel;charset=GBK");
PrintWriter out=response.getWriter();
out.println("1234567891123154546456\t4564564587784213444112454");
//上面的1234567891123154546456数值,在导出EXECL时 以 文本格式 显示,而不是 常规格式。
知道方法的兄弟帮忙看看。
给出代码是最好了。
request.setCharacterEncoding("GBK");
response.setContentType("application/vnd.ms-excel;charset=GBK");
PrintWriter out=response.getWriter();
out.println("1234567891123154546456\t4564564587784213444112454"); 1234567891123154546456 这个数 存到 EXECL表格中,它在EXECL却显示成1.23457E+21 ,而我要它还是显示成1234567891123154546456 这样说明白了吗???应该怎么写?