Rising Sun

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評論 :: 0 Trackbacks
          String cl=new String(req.getParameter("checkboxvalue").getBytes("iso8859-1"),"gb2312");

          excel

          ?Connection connection = DbConnectionManager.getConnection();
          ??????? try{
          ??????????
          ??????? ?
          ??????????? PreparedStatement prst = connection.prepareStatement(sql);
          ??????????? ResultSet rs = prst.executeQuery();
          ??????????? if(rs.next()){
          ??????????? ?//if(rs == null){rs.close();
          ??????????????? Blob blob = rs.getBlob("bb");
          ?????????????
          ??????????????? byte[] ab = blob.getBytes(1, (int)blob.length());
          ??????????????? //URLEncoder.encode(rname, "utf-8");
          ??????????????? //new String("文件名.xls".getBytes("GBK"),"ISO8859_1")
          ??????????????? //response.setHeader("Charset","gb2312");
          ??????????????? //application/msexcel-comma
          ??????????????? String fs = new String(rname.getBytes("GBK"),"ISO8859_1");
          ????????????????
          ??????????????? response.reset();
          ??????????????? response.setLocale(java.util.Locale.CHINA);
          ??????????????? response.setContentType("application/vnd.ms-excel");
          ??????????????? request.setCharacterEncoding("GBK");
          ??????????????
          ??????????????
          ??????????????? String s = "attachment; filename="+fs;
          ??????????????? response.setHeader("Content-Disposition", s);
          ??????????????? ServletOutputStream op = response.getOutputStream();
          ??????????????? op.write(ab);
          ??????????????? op.flush();
          ??????????????? op.close();
          ??????????? }
          ???????? }catch(SQLException e){
          ??????? log.info(e.toString()+"sql:"+sql);
          ???? }
          ???????? catch(NullPointerException ex){
          ??????? ? System.out.print("數據為空");
          ???????? }
          ????????
          ???????? finally{
          ???????? try{
          ???????? connection.close();
          ?????? }catch(Exception e){
          ???? ?? System.out.print("ddd");
          ?????? }
          posted on 2006-07-18 16:26 brock 閱讀(197) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 庆元县| 紫阳县| 任丘市| 崇左市| 泌阳县| 绥化市| 景洪市| 昔阳县| 登封市| 边坝县| 深州市| 武义县| 天全县| 定结县| 宁安市| 莆田市| 德阳市| 平乐县| 柘荣县| 湖州市| 靖江市| 龙胜| 洱源县| 清远市| 凤凰县| 广昌县| 固阳县| 瓮安县| 怀宁县| 府谷县| 广饶县| 疏勒县| 星子县| 青河县| 广丰县| 商水县| 隆德县| 辉南县| 南阳市| 修文县| 县级市|