用jsp程序在服务器端查询数据并且显示出来 点击复选框把选中的数据以excel的格式下载到客户端该怎么解决?希望提供详细的例子程序、先谢谢各位大哥、、、、 

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【handongqi415】截止到2008-07-11 12:06:53的历史汇总数据(不包括此帖):
    发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:---------------------结分的百分比:---------------------
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    去网上找java 操作excel的例子....
    有个jxl.jar包
      

  3.   

    jxl的示例
    servlet代码:
    response.setContentType("application/vnd.ms-excel");
    // 生成EXCELL文件流
    OutputStream os = response.getOutputStream();
    try {
    WritableWorkbook workbook = Workbook.createWorkbook(os);
    WritableSheet report = workbook.createSheet("报表", 0);
    WritableCellFormat alignWay = new WritableCellFormat();
    alignWay.setAlignment(jxl.format.Alignment.CENTRE);
    // 列标题
    int index = 0;
    Label id = new Label(index++, 0, "序号", alignWay);
    report.addCell(id);
    Label acshortname = new Label(index++, 0, "委托客户", alignWay);
    report.addCell(acshortname);
    Label begincity = new Label(index++, 0, "起始地", alignWay);
    report.addCell(begincity);
    Label endcity = new Label(index++, 0, "目的地", alignWay);
    report.addCell(endcity);
    // 数据
    if (list != null && list.size() > 0) {
    for (int i = 0; i < list.size(); i++) {
    BuTransVo vo = (BuTransVo) list.get(i);
    int _index = 0;
    Number _id = new Number(_index++, i + 1, i + 1, alignWay);
    report.addCell(_id);
    Label _acshortname = new Label(_index++, i + 1, vo.getacShortName(), alignWay);
    report.addCell(_acshortname);
    Label _begincity = new Label(_index++, i + 1, vo.gettoBeginC(), alignWay);
    report.addCell(_begincity);
    Label _endcity = new Label(_index++, i + 1, vo.gettoEndC(), alignWay);
    report.addCell(_endcity);

    }
    }
    workbook.write();
    workbook.close();
    os.flush();
    os.close();
    } catch (Exception e) { }
    request.setAttribute("fileName", reportName);