开发者社区> 问答> 正文

Poirender到不的Excel在哪里?报错

public void exportExcel()
{
String[] columns = new String[] { "ACC_NBR", "DEVID", "IMSI" };
   String[] headers = new String[] { "电话号码", "设备id", "imsi", "最后上线时间" };
   String[] headers2 = new String[] { "电话号码", "设备id", "imsi" };
List<Object> data = Lists.newArrayList();
        for (int i = 0; i < 5; i++) {
            Map<String, Object> map = getMap(i);
            data.add(map);
        }
        render(PoiRender.me(data).fileName("your_file_name.xls").headers(headers).cellWidth(5000).headerRow(2));

}

这样导出之后的Excel文件在哪了?没有报错,找不到Excel文件

展开
收起
爱吃鱼的程序员 2020-06-14 18:05:48 387 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    将"your_file_name.xls"改为"d:/your_file_name.xls"试试,然后去d盘根目录下面去找那个文件我这样也试过了,可是还是没有那个文件,在什么情况下不会生成文件吗?没有异常啊

    在web环境下在一个actionmethod中执行,浏览器会直接下载这个文件.

    非web环境用这样的方式.

    Workbookworkbook=PoiKit.<spanstyle="background-color:#344134;">data(data).sheetName(<spanstyle="color:#6a8759;">"data").columns(<spanstyle="color:#6a8759;">"name").headers(<spanstyle="color:#6a8759;">"A").export()<spanstyle="color:#cc7832;">;

    <spanstyle="color:#cc7832;">

    Stringpathname=PathKit.<spanstyle="font-style:italic;">getRootClassPath()+<spanstyle="color:#6A8759;">"/excel.xls"<spanstyle="color:#CC7832;">;
    <spanstyle="font-size:9pt;line-height:1.5;"><spanstyle="font-size:9pt;line-height:1.5;background-color:#344134;">System<spanstyle="font-size:9pt;line-height:1.5;">.<spanstyle="font-size:9pt;line-height:1.5;color:#9876AA;font-style:italic;">out<spanstyle="font-size:9pt;line-height:1.5;">.println(pathname)<spanstyle="font-size:9pt;line-height:1.5;">;<spanstyle="font-size:9pt;line-height:1.5;">workbook.write(<spanstyle="font-size:9pt;line-height:1.5;">new<spanstyle="font-size:9pt;line-height:1.5;">FileOutputStream(<spanstyle="font-size:9pt;line-height:1.5;">new<spanstyle="font-size:9pt;line-height:1.5;">File(pathname)))<spanstyle="font-size:9pt;line-height:1.5;">;

    <spanstyle="color:#cc7832;">

    <spanstyle="color:#cc7832;">

    
    

    2020-06-14 18:06:07
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多