<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
    主站蜘蛛池模板: 黄色一级毛片免费看| 亚洲免费福利视频| 三年片在线观看免费观看大全中国| 国产色爽免费视频| 欧洲 亚洲 国产图片综合| 搜日本一区二区三区免费高清视频 | 免费看内射乌克兰女| 亚洲综合色成在线播放| 一区二区三区免费精品视频| 亚洲欧洲精品成人久久奇米网 | 亚洲视频在线免费看| 亚洲人成网站色在线观看| 67194熟妇在线永久免费观看| 亚洲黄色免费观看| 丁香花免费高清视频完整版| 亚洲永久网址在线观看| 99热在线免费观看| 亚洲日韩国产精品无码av| 99热在线精品免费全部my| 亚洲欧美不卡高清在线| 免费a级毛片在线观看| 国产激情久久久久影院老熟女免费 | 青青草原1769久久免费播放| 成年人视频在线观看免费| 亚洲人成网站18禁止| 亚洲JIZZJIZZ中国少妇中文| 中文字幕免费播放| 亚洲第一页在线视频| 国产精品另类激情久久久免费| 国产大片免费天天看| 亚洲天堂中文字幕| 91福利免费网站在线观看| 免费中文字幕一级毛片| 国产精品免费看久久久香蕉| 亚洲一本综合久久| 国产精品久免费的黄网站| 国内精品久久久久影院免费| 亚洲一级特黄特黄的大片| 亚洲成人免费电影| 成人一级免费视频| 亚洲无吗在线视频|