栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java提交浏览器下载excel

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java提交浏览器下载excel

java提交浏览器下载excel
public void excel(HttpServletResponse response) throws IOException {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("法人");//定义一个表名
        HSSFRow row=null;
        for(int i=0;i<5;i++){
             row = sheet.createRow(i);//定义第一行
            row.createCell(0).setCellValue("序号");//列标题
            row.createCell(1).setCellValue("账号");
            row.createCell(2).setCellValue("");
            row.createCell(3).setCellValue("起期");
            row.createCell(4).setCellValue("止期");
            row.createCell(5).setCellValue("");
            row.createCell(6).setCellValue("部门");
            }
        OutputStream outStream = response.getOutputStream();
        response.reset();
        response.setContentType("application/vnd.ms-excel;charset=GBK");
        response.setHeader("Content-Disposition",
                new String("attachment;filename=工作簿.xls".getBytes("GBK"),
                        "ISO8859-1"));

        try {
            workbook.write(outStream);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            outStream.close();
        }
        }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/919711.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号