Rising Sun

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評(píng)論 :: 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("數(shù)據(jù)為空");
          ???????? }
          ????????
          ???????? finally{
          ???????? try{
          ???????? connection.close();
          ?????? }catch(Exception e){
          ???? ?? System.out.print("ddd");
          ?????? }
          posted on 2006-07-18 16:26 brock 閱讀(197) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 玉门市| 始兴县| 武定县| 松桃| 会宁县| 普定县| 青阳县| 汨罗市| 白河县| 郑州市| 三台县| 靖西县| 班戈县| 图木舒克市| 汶上县| 肇东市| 吉林省| 酒泉市| 石屏县| 梁山县| 乌兰察布市| 娱乐| 曲水县| 宁南县| 宿迁市| 元江| 新密市| 台北市| 平度市| 焉耆| 长武县| 黄山市| 凤冈县| 两当县| 洛阳市| 随州市| 洛南县| 同心县| 台中市| 女性| 交口县|