使用easypoi 导入excel

使用easypoi 导入excel

一、pom文件

		
            cn.afterturn
            easypoi-base
            3.0.3
        
        
            cn.afterturn
            easypoi-web
            3.0.3
        
        
            cn.afterturn
            easypoi-annotation
            3.0.3
        

二、创建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 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));
	}



你可能感兴趣的:(使用easypoi 导入excel)