HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
HSSFRow row = null;
HSSFCell cell = null;
int i = 1; //
int writeadd = 0;
String cellvalue = ""; //
JsUserBasicData jub = new JsUserBasicData();
row = sheet.createRow(0);
cell = row.createCell((short) 0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("姓名");
cell = row.createCell((short) 1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("性别");
cell = row.createCell((short) 2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("学历");
cell = row.createCell((short) 3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("工作经验");
cell = row.createCell((short) 4);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("手机号码");
while (rs.next()) {
System.out.println("正在生成第" + i + "条记录");
ResultSetMetaData rsmd = rs.getMetaData();
row = sheet.createRow((short) i);
int colcount = rsmd.getColumnCount();
for (int icc = 0; icc < colcount; icc++) {
cellvalue = rs.getString(icc + 1);
if(icc==1) {
int sex = StringUtil.parseInt(cellvalue);
if(sex == 1) cellvalue="男";
else if(sex == 2) cellvalue="女";
}
if(icc==2) {
int temp = StringUtil.parseInt(cellvalue);
if(temp==0) cellvalue="不限";
if(temp==1) cellvalue="初中";
if(temp==2) cellvalue="高中";
if(temp==3) cellvalue="中专";
if(temp==4) cellvalue="大专";
if(temp==5) cellvalue="本科";
if(temp==6) cellvalue="硕士";
if(temp==7) cellvalue="MBA";
if(temp==8) cellvalue="博士";
if(temp==9) cellvalue="培训";
}
cell = row.createCell((short) icc);
System.out.println("md:" + cellvalue);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(cellvalue);
}
i++;
}