Giter Site home page Giter Site logo

jueyue / easypoi Goto Github PK

View Code? Open in Web Editor NEW
135.0 135.0 25.0 3.2 MB

POI tool, excel quick import and export, excel template export, word template export, can complete the import and export of Excel in only 5 lines of code, the modification and export format is simple, rough, fast and effective, easypoi is worth your try

Home Page: http://opensource.afterturn.cn

License: Apache License 2.0

Batchfile 0.01% Java 99.85% CSS 0.14%

easypoi's People

Contributors

antelop304 avatar cowsmiles avatar dilykat avatar jamsw avatar jayzch avatar kgdngitfk avatar lihanxie avatar liuyaoduan avatar mai11 avatar maijh97 avatar nieqiurong avatar oneplustow avatar plq2017 avatar wind3 avatar wqhyw avatar zhanghqgit avatar zhetz avatar zhuhuawu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

easypoi's Issues

模板导出excel打不开

版本 4.1.2
模板导出excel打不开
1575776819(1)
1575776863(1)
代码:
list["list"] = orderList
modelMap[TemplateExcelConstants.FILE_NAME] = UUID.randomUUID().toString().replace("-", "")
modelMap[TemplateExcelConstants.PARAMS] = params
modelMap[TemplateExcelConstants.MAP_DATA] = list
PoiBaseView.render(modelMap, this.request, this.response, TemplateExcelConstants.EASYPOI_TEMPLATE_EXCEL_VIEW)
就算用一个空白模板也打不开
模板:
test.xlsx

wps可以正常打开

ExcelExportEntity 排序bug

ExcelExportEntity

@Override public int compareTo(ExcelExportEntity prev) { return this.getOrderNum() - prev.getOrderNum(); }
这个方法在 int 最小值边界 出现排序bug

easypoi-spring-boot-starter 导出图片,4.4.0无,4.2.0有

问题:导出图片,使用easypoi-spring-boot-starter 4.4.0 导出表格无图片,使用4.2.0有(经过反复对比测试)
补充:@Excel注解形式,以下代码,切换4.2.0,导出表格有图,切换到4.4.0,无图
代码:

        List<ImageInfo> result = new ArrayList<>();
        ImageInfo imageInfo = new ImageInfo();
        imageInfo.setImgName("图片名1");
        imageInfo.setImgUrl("2.jpg");
        result.add(imageInfo);

        String fileName = "图片信息表.xlsx";
        ExportParams exportParams = new ExportParams();
        exportParams.setType(ExcelType.XSSF);
        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ImageInfo.class, result);

        File file = new File(fileName);
        OutputStream fos = new FileOutputStream(file);
        workbook.write(fos);
        workbook.close();
        fos.close();

复杂表头时列名映射错误

如图所示表格,一对多的情况下,附加关联的 List 集合的部分映射没有问题,但普通列的第一列列名解析错误

QQ截图20220610152503

复现步骤:

一.定义关联类如下

1.关联类

@Data
public class DicPoi {
    @Excel(name = "* 字段名称", needMerge = true)
    private String name;

    @Excel(name = "* 字段编码", needMerge = true)
    private String code;

    @Excel(name = "* 字段类型", needMerge = true)
    private String type;

    @Excel(name = "* 数据长度", needMerge = true)
    private Long length;

    @ExcelCollection(name = "关联API")
    private List<DicApi> dicApiList;

    @ExcelCollection(name = "关联画像")
    private List<DicProfile> dicProfileList;
}

2.两个子关联集合类

@Data
public class DicApi {
    @Excel(name = "API名称")
    private String name;

    @Excel(name = "入参/出参")
    private String paramType;

    @Excel(name = "参数名称")
    private String paramName;

    @Excel(name = "参数code")
    private String paramCode;
}

@Data
public class DicProfile {
    @Excel(name = "画像名称")
    private String profileName;

    @Excel(name = "因子名称")
    private String paramName;

    @Excel(name = "因子编码")
    private String paramCode;
}

二.运行测试代码

public class Test {
    public static void main(String[] args) {
        String filePath = "/opt/导入示范模板.xlsx";
        ImportParams params = new ImportParams();
        params.setNeedVerfiy(true);
        params.setTitleRows(1);
        params.setHeadRows(2);
        ExcelImportResult<DicPoi> result = ExcelImportUtil.importExcelMore(new File(filePath), DicPoi.class, params);
        for (DicPoi dicPoi : result.getList()) {
            System.out.println(dicPoi);
        }
    }
}

三.运行

运行后,sout 输出内容

DicPoi(name=null, code=U0010001, type=字符型, length=8, dicApiList=[DicApi(name=身份信息查询, paramType=输出参数, paramName=姓名, paramCode=xm), DicApi(name=人员资质信息, paramType=输出参数, paramName=姓名, paramCode=name)], dicProfileList=[DicProfile(profileName=用户画像, paramName=姓名, paramCode=name), DicProfile(profileName=null, paramName=null, paramCode=null)])

可以看到关联的 name 属性读取为 null。遂打断点调试,运行至 cn.afterturn.easypoi.excel.imports.ExcelImportServer#importExcel 134行

Map<Integer, String> titlemap = this.getTitleMap(rows, params, excelCollection);

到此发现 titlemap 值不对,第一列标题被归纳到了上一级,与注解中 name 属性的列名映射不一致所以才会出现读取为 null 的情况,不知道是我的用法不对还是复杂表头映射的问题呢。

image

replace使用

image
这一块能不能加个字符串的trim?如果excel里面有空格,根本replace不了啊

丢失数据&导出数据速度很慢

ExcelBatchExportService batchServer = new ExcelBatchExportService();
batchServer.write()

前提:导出的数据列有一百多列,一万多行
batchServer.write()每次处理500条数据
问题:
1、最有只导出五千多条,存在丢数据(已从日志确认所有数据都走batchServer.write()方法,部分调用响应时间不超过1分钟,可以确定没有真正的处理数据)
2、batchServer.write() 响应时间太慢,500条数据,大概要处理8分钟到20分钟不等。(不确定真正处理完500条的时间)

老哥 ExcelImportService.importExcelByIs 这个地方有一个needMore的参数为true的时候异常的慢

老哥 ExcelImportService.importExcelByIs 这个地方有一个needMore的参数 , 这个参数会导致清除多余的行
这个操作会导致遍历的层级是cell * row * cell 的数量级...之前看到这个importExcelMore是以为专门用来导入大数据集的,但是这个地方实际情况因为这个清除多余的行的操作,异常的慢,...这个之前的涉及意图是什么

PoiValidationUtil 自定义校验返回message字段名重复问题

正常我们通过校验字段时,会加上name,这就会导致返回的errorMsg上出现重复字段名的问题
如字段注解如下
@Excel(name = "姓名") @ApiModelProperty(value = "姓名") @NotBlank(message = "姓名不能为空") @Length(max = 30, message = "姓名请少于{max}字") private String username;

实际错误信息会返回
第2条记录,数据校验不通过,原因:姓名姓名不能为空

csv 文件导出没有那种¥或者%格式

之前excel 导出 exportParams.setStyle(CommonExcelStyle.class);用了这个定义了样式
里面有 cellStyle.setDataFormat(format);

现在改成了csv 导出,但是没有之前的格式了。
有什么破解的方法???

在线求解,谢谢

When using sax import, fixedIndex will result in entity's property is null

When I using sax and fixedIndex to import big data list, the result entity's property will be null.

Code Version: master

The entiy is:

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import lombok.Data;

import java.util.Date;

@Data
public class WorkDingDetail {
    @ExcelIgnore
    private Integer id;

    @Excel(name = "姓名", fixedIndex = 0)
    private String name;

    @Excel(name = "工号", fixedIndex = 3)
    private String userNo;

    @Excel(name = "日期", format = "yy-MM-dd", fixedIndex = 6)
    private Date date;

    @Excel(name = "上班1打卡时间", fixedIndex = 8)
    private String clockIn;

    @Excel(name = "下班1打卡时间", fixedIndex = 10)
    private String clockOut;
}

The excel file is:
公司钉钉打卡统计.xlsx

关于PoiBaseView EasypoiBigExcelExportView 导出建议

1,在easypoiPoiBaseView实现类EasypoiBigExcelExportView#renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,HttpServletResponse response)方法,我们需要实现IExcelExportServer,
个人觉得这种方式不够灵活,或许可以交给用户去做,如ExcelExportUtil#exportBigExcel(exportParams, pojoClass, dataSet)根据Workbook#write
2.希望大数据导出时能够多sheet页,并且每一个sheet页都能设置title等

4.4.0版本excel导出图片失败,excel里没有图片显示,4.3.0版本可以正常导出图片

依赖版本4.4.0

    <!--EasyPoi相关依赖-->
    <dependency>
        <groupId>cn.afterturn</groupId>
        <artifactId>easypoi-spring-boot-starter</artifactId>
        <version>4.4.0</version>
    </dependency>

实体类

@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class CompanyHasImgModel {
    @Excel(name = "公司名称", type = 1, width = 20, height = 20)
    private String name;

    //4.4.0版本excel导出图片报错,换成4.3.0导出成功
    @Excel(name = "公司LOGO", type = 2, width = 80, height = 50)
    private String companyLogo;

    @Excel(name = "公司地址", type = 1, width = 20, height = 20)
    private String address;
}

测试类

public class MallTinyApplicationTests {

    @Test
    public void contextLoads() {
    }

    List<CompanyHasImgModel> list;

    @Before
    public void initData() {
        list = new ArrayList<>();
        list.add(new CompanyHasImgModel("百度",
                "D:\\yang\\Pictures\\蜂蜜浏览器_123.jpg",
                "北京市海淀区西北旺东路10号院百度科技园1号楼"));
        /*list.add(new CompanyHasImgModel("阿里巴巴", "imgs/company/ali.png", "北京市海淀区西北旺东路10号院百度科技园1号楼"));
        list.add(new CompanyHasImgModel("Lemur", "imgs/company/lemur.png", "亚马逊热带雨林"));
        list.add(new CompanyHasImgModel("一众", "imgs/company/one.png", "山东济宁俺家"));*/


    }

    @Test
    public void exportCompanyImg() throws Exception {

        File savefile = new File("D:\\yang\\Downloads\\");
        if (!savefile.exists()) {
            savefile.mkdirs();
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), CompanyHasImgModel.class, list);
        FileOutputStream fos = new FileOutputStream("D:\\yang\\Downloads\\ExcelExportHasImgTest.exportCompanyImg.xls");
        workbook.write(fos);
        fos.close();
    }

}

excel
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.