利用XLSTransformer生成excel

XLSTransformer transformer = new XLSTransformer();
        String distFile = System.getProperty("java.io.tmpdir") + "/" + fileName + ".xls";
        File template = ResourceUtils.getFile("classpath:template/excel/" + name + ".xls");
        transformer.transformXLS(template.getPath(), beans, distFile);
        response.setContentType("application/xls");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".xls\"");
        StreamUtils.copy(new FileInputStream(new File(distFile)), response.getOutputStream());

猜你喜欢

转载自849058520.iteye.com/blog/2204551