zoukankan      html  css  js  c++  java
  • 导出生成xsl文件

    public String expData() throws Exception{
            
        List<SubArea> list = subAreaService.findAll();
        
        HSSFWorkbook hssf = new HSSFWorkbook();
        HSSFSheet sheet = hssf.createSheet("分页信息");
        HSSFRow titleRow = sheet.createRow(0);
            
        titleRow.createCell(0).setCellValue("分区编号");
        titleRow.createCell(1).setCellValue("所属省份");
        titleRow.createCell(2).setCellValue("所属城市");
        titleRow.createCell(3).setCellValue("所属区域");
        for (SubArea subArea: list) {
            HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
            dataRow.createCell(0).setCellValue(subArea.getId());
            dataRow.createCell(1).setCellValue(subArea.getArea().getProvince());
            dataRow.createCell(2).setCellValue(subArea.getArea().getCity());
            dataRow.createCell(3).setCellValue(subArea.getArea().getDistrict());
        }
        ServletOutputStream out = ServletActionContext.getResponse().getOutputStream();
        ServletActionContext.getResponse().setContentType("application/vnd.ms-excel");
        String fileName = "分区数据.xls";
        String agent = ServletActionContext.getRequest().getHeader("User-Agent");
        fileName =     FileUtils.encodeDownloadFilename(fileName, agent);
            ServletActionContext.getResponse().setHeader("content-disposition", "attachment;filename="+fileName );
            hssf.write(out);
            return NONE;
        }
  • 相关阅读:
    Android的LinearLayout中的权重android:layout_weight
    iPhone尺寸规范
    导出iPhone中安装的APP的iPA文件
    c++ json字符串转换成map管理
    mac 升级EI Capitan后遇到c++转lua时遇到libclang.dylib找不到的错
    sqlite3 数据库使用
    关于flyme5显示不到和卸载不到旧应用解决方法
    cocos2dx 通过jni调用安卓底层方法
    cocos2dx 单张图片加密
    安卓线程使用问题
  • 原文地址:https://www.cnblogs.com/guanzhuang/p/8214913.html
Copyright © 2011-2022 走看看