<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 0,  comments - 5,  trackbacks - 0

    要用到poi-2.5.1-final-20040804.jar包

    ?1 import ?java.io.FileOutputStream;
    ?2 import ?java.sql.Connection;
    ?3 import ?java.sql.ResultSet;
    ?4 import ?java.sql.ResultSetMetaData;
    ?5
    ?6 import ?org.apache.poi.hssf.usermodel.HSSFCell;
    ?7 import ?org.apache.poi.hssf.usermodel.HSSFRow;
    ?8 import ?org.apache.poi.hssf.usermodel.HSSFSheet;
    ?9 import ?org.apache.poi.hssf.usermodel.HSSFWorkbook;
    10 import ?org.dom4j.Document;
    11 import ?org.dom4j.Element;
    12
    13 import ?wufalong.exportServer.ConnectBean;
    14 import ?wufalong.exportServer.CreateConnection;
    15 import ?wufalong.exportServer.GetResultSet;
    16 import ?wufalong.exportServer.LoadRootElementByConfigFile;
    17 import ?exportxls.JsUserBasicData;
    18
    19 public ? class ?Person20070517
    20 {
    21 ?? public ? static ? void ?main(String?args[])?
    22 ?? {
    23 ??????Person20070517?c = new ?Person20070517();
    24 ?????? int ?allcount = 0 ;
    25 ??????allcount = allcount + c.createPersonMobile( " c:/人才.xls " );
    26 ??}

    27 ??
    28 ?? public ? int ?createPersonMobile(String?filename)
    29 ?? {
    30 ??????Connection?con? = ? null ;
    31 ??????ResultSet?rs? = ? null ;
    32 ??????Document?doc? = ?LoadRootElementByConfigFile.getRootElement();
    33 ??????Element?e? = ?doc.getRootElement().element( " import " );
    34 ?????? try
    35 ?????? {
    36 ????????????con? = ?CreateConnection.getConnect(e);
    37 ????????????rs? = ?GetResultSet.getResule(con,ConnectBean.getSql(e));
    38 ??????????FileOutputStream?fOut? = ? null ;
    39 ??????????HSSFWorkbook?workbook? = ? new ?HSSFWorkbook();
    40 ??????????HSSFSheet?sheet? = ?workbook.createSheet();
    41 ??????????HSSFRow?row? = ? null ;
    42 ??????????HSSFCell?cell? = ? null ;
    43 ?????????? int ?i? = ? 1 ;
    44 ?????????? int ?writeadd? = ? 0 ;
    45 ??????????String??cellvalue? = ? "" ;
    46 ??????????JsUserBasicData?jub? = ? new ?JsUserBasicData();
    47 ??????????row? = ?sheet.createRow( 0 );
    48 ??????????cell? = ?row.createCell(( short )? 0 );
    49 ??????????cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    50 ??????????cell.setEncoding(HSSFCell.ENCODING_UTF_16);
    51 ??????????cell.setCellValue( " 姓名 " );
    52 ??????????cell? = ?row.createCell(( short )? 1 );
    53 ??????????cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    54 ??????????cell.setEncoding(HSSFCell.ENCODING_UTF_16);
    55 ??????????cell.setCellValue( " 手機 " );
    56 ??????????
    57 ?????????? while ?(rs.next())? {
    58
    59 ??????????????System.out.println( " 正在生成第 " ? + ?i? + ? " 條記錄 " );
    60 ??????????????ResultSetMetaData?rsmd? = ?rs.getMetaData();
    61 ??????????????row? = ?sheet.createRow(( short )?i);
    62 ?????????????? int ?colcount? = ?rsmd.getColumnCount();
    63 ?????????????? for ?( int ?icc? = ? 0 ;?icc? < ?colcount;?icc ++ )? {
    64 ??????????????????cellvalue? = ?rs.getString(icc? + ? 1 );?
    65 ??????????????????cell? = ?row.createCell(( short )?icc);
    66 ??????????????????System.out.println( " md: " ? + ?cellvalue);?
    67 ??????????????????cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    68 ??????????????????cell.setEncoding(HSSFCell.ENCODING_UTF_16);
    69 ??????????????????cell.setCellValue(cellvalue);
    70 ??????????????}

    71 ??????????????i ++ ;
    72 ??????????}

    73
    74 ??????????fOut? = ? new ?FileOutputStream(filename);
    75 ??????????workbook.write(fOut);
    76 ??????????fOut.flush();
    77 ??????????fOut.close();
    78 ??????????System.out.println(filename? + ? " 文件生成 " ? + ?i? + ? " " );
    79 ??????????rs.close();
    80 ??????????rs? = ? null ;
    81 ??????????con.close();
    82 ??????????con? = ? null ;
    83 ?????????? return ?i;
    84 ??????}
    ? catch ?(Exception?ee)?
    85 ?????? {
    86 ??????????????System.out.println( " 發生了 " ? + ?ee.getMessage()? + ? " 例外 " );
    87 ??????}
    ?
    88 ?????? finally ?
    89 ?????? {
    90 ??????????????GetResultSet.closeResultSet(rs);
    91 ??????????????CreateConnection.closeConnect(con);
    92 ??????}

    93 ????? return ? 0 ;
    94 ??}

    95 }

    96
    posted on 2007-09-03 13:56 crazy 閱讀(1788) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 高h视频在线免费观看| 国产在线a免费观看| 亚洲精品视频在线免费| va亚洲va日韩不卡在线观看| 一级毛片免费播放| 免费A级毛片无码视频| 免费A级毛片无码视频| 99久热只有精品视频免费看| 99久久99这里只有免费费精品| 99精品全国免费观看视频..| 国产乱妇高清无乱码免费| 99在线观看免费视频| 一级成人a毛片免费播放| 好男人www免费高清视频在线| 色妞WWW精品免费视频| 免费人成在线观看网站视频 | 亚洲AV无码成人精品区蜜桃| 在线观看成人免费视频不卡| 免费在线一级毛片| 国产精品亚洲片在线va| 亚洲视频免费在线播放| 在线观看人成视频免费| 91麻豆国产免费观看| 国产青草亚洲香蕉精品久久| 亚洲av午夜福利精品一区| 天天操夜夜操免费视频| 日韩免费电影网站| 污污免费在线观看| 色天使亚洲综合在线观看| 亚洲国产精品第一区二区 | 毛色毛片免费观看| 欧洲人成在线免费| 免费福利在线观看| 亚洲乱码在线观看| 亚洲黄色网站视频| 亚洲色婷婷六月亚洲婷婷6月| 国产禁女女网站免费看| 国产又黄又爽又猛免费app| 99re在线视频免费观看| 中文字幕免费视频精品一| 免费无码又爽又黄又刺激网站|