zoukankan      html  css  js  c++  java
  • POI导出

    public void export(){
    try {
    String columns = getPara("nameArray");
    List<Record> list = SimpleService.export(columns);
    HSSFWorkbook wb = new HSSFWorkbook(); //创建excel文件
    HSSFSheet sheet = wb.createSheet(); //创建工作单
    String[] columnArray = columns.split(",");
    this.exportHeader(sheet, columns); //创建表头
    for(int i =0;i<list.size();i++){
    Record record = list.get(i);
    HSSFRow row = sheet.createRow(i+1);
    for(int j = 0;j<columnArray.length;j++){
    String column = columnArray[j].split("\.")[1];
    HSSFCell cell = row.createCell(j);
    if(record.get(column)!=null){
    cell.setCellValue(record.get(column).toString());
    }
    }
    }
    OutputStream outputStream = getResponse().getOutputStream();
    getResponse().setHeader("content-disposition", "attachment;filename="+ new String("月销售数据.xls".getBytes("gb2312"), "iso8859-1"));
    wb.write(outputStream);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

  • 相关阅读:
    asp.net读取/导入project(mpp)文件
    hdu2103
    hdu2100(大数加)
    hdu1406
    hdu1249
    hdu1038
    hdu2565
    hdu1203
    zoj3501
    hdu2102
  • 原文地址:https://www.cnblogs.com/chenweichu/p/5576661.html
Copyright © 2011-2022 走看看