使用easypoi 导入excel

使用easypoi 导入excel

一、pom文件

		<dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-base</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-web</artifactId>
            <version>3.0.3</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-annotation</artifactId>
            <version>3.0.3</version>
        </dependency>

二、创建pojo类

public class InstallationUser {
@Excel(name = “姓名”,orderNum = “0”)
private String name;
@Excel(name = “年龄”,orderNum = “1”)
private String age;
@Excel(name = “性别”,orderNum = “2” ,replace={“男_0”,“女_1”})
private String sex;

三、测试

	@Test
	public void test(){
			ImportParams params = new ImportParams();
			params.setStartSheetIndex(1);//第几个sheet从0开始
			params.setTitleRows(0);//表格标题行数,默认0
			params.setHeadRows(1);//表头行数,默认1
			long start = new Date().getTime();
			List<InstallationUser> list = ExcelImportUtil.importExcel(
					new File("C:\\Users\\Administrator\\Desktop\\sheet\\安装批量导入.xlsx"),
					InstallationUser.class, params);
			System.out.println(new Date().getTime() - start);
			System.out.println(list.size());
			for (InstallationUser installationUser : list) {
				System.out.println(installationUser);
			}
			System.out.println(ReflectionToStringBuilder.toString(list));
	}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值