String start_time1=" and to_date(to_char(recive_time,'yyyy-mm-dd'),'yyyy-mm-dd')>=to_date('"+start_time+"','yyyy-mm-dd')"; String end_time1=" and to_date(to_char(recive_time,'yyyy-mm-dd'),'yyyy-mm-dd')<=to_date('"+end_time+"','yyyy-mm-dd')";
strsql="select e.employee_id,e.employee_name,y.recive_time,y.content from employee_info e,yj_info y where e.employee_id=y.employee_id and y.employee_id = "+employee_id+" and is_qj=0 and is_ok=1 "+start_time1+end_time1; System.out.println(strsql); conn.executeQuery(strsql,rs); while(rs.next()) {
out.close();
<%
//生成Excel代码
HSSFWorkbook workbook = new HSSFWorkbook(); //创建新的Excel工作薄
HSSFSheet sheet = workbook.createSheet("合格数量"); //在Excel工作薄中建工作表,名为缺省
HSSFRow row;
HSSFCell cell;
int row_id=0;
int cell_id=0;
row= sheet.createRow((short)0); //在索引0的位置建行(最顶端的行)
cell = row.createCell((short)0); //在索引0的位置建单元格
cell.setEncoding(HSSFCell.ENCODING_UTF_16); //定义单元格为字符串类型
cell.setCellValue("员工名称"); //在单元格输入一些内容
cell = row.createCell((short)1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("发送内容");
cell = row.createCell((short)2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("发送短信时间");
cell = row.createCell((short)3);
String start_time1=" and to_date(to_char(recive_time,'yyyy-mm-dd'),'yyyy-mm-dd')>=to_date('"+start_time+"','yyyy-mm-dd')";
String end_time1=" and to_date(to_char(recive_time,'yyyy-mm-dd'),'yyyy-mm-dd')<=to_date('"+end_time+"','yyyy-mm-dd')";
strsql="select e.employee_id,e.employee_name,y.recive_time,y.content from employee_info e,yj_info y where e.employee_id=y.employee_id and y.employee_id = "+employee_id+" and is_qj=0 and is_ok=1 "+start_time1+end_time1;
System.out.println(strsql);
conn.executeQuery(strsql,rs);
while(rs.next())
{
row_id++;
row = sheet.createRow(row_id); //在索引1的位置创建行
cell = row.createCell((short)0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(rs.getString("employee_name"));
cell=row.createCell((short)1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(rs.getString("content"));
cell=row.createCell((short)2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(rs.getString("recive_time"));
cell=row.createCell((short)3);
}
String filename = "file/"+"hegeshuliang"+".xls";
String filename_all = application.getRealPath("/")+ filename;
//filename是工作薄的存放位置,存放在当前应用程序的根目录下
FileOutputStream fOut = new FileOutputStream(filename_all); //新建输出文件流
workbook.write(fOut); //把相应的Excel工作薄存盘
fOut.flush();
fOut.close(); //操作结束,关闭文件 out.println("<td>已生成excel文件:<A HREF='../"+filename+"'>" + filename+ "请点右键选择另存为进行下载</A></td>");
%>