1 Star 1 Fork 1

星空倒影 / easyexcel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
星空倒影 提交于 2016-07-11 17:07 . 注释。。。。

#easyexcel

###以前看到一个注解读写excel的工程。。。实在忘记他叫啥了。。。

##特性

  • 注解支持
  • 格式化支持

##code example


#Book

	//PropertyCell 可以指定自定义cell处理器  具体实现看 format包      format=AAFormat.class  formatParam="xxx" 这个会作为AAFormat 的参数, order 参数为写入excel的顺序

	@PropertyCell(title="id")
	private Integer id;
	
	@PropertyCell(title="名称")
	private String name;
	
	@PropertyCell(title="数量")
	private Integer count;
	
	@PropertyCell(title="创建日期", formatParam="yyyy-MM-dd")
	private Date createDate;

	@Test
	public void readTest() {
		try {
			List<Book> bookList = ExcelHelper.readList(this.getClass().getResource("/test.xlsx").getPath(), Book.class);
			printList(bookList);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void writeTest() {
		try {
			List<Book> bookList = new ArrayList<Book>();
			for (int i = 0; i < 5; i++) {
				Book book = new Book();
				book.setId(i);
				book.setName("书名_" + i);
				book.setCount(RandomUtils.nextInt(100));
				bookList.add(book);
			}
			printList(bookList);
			System.out.println();
			String path = this.getClass().getResource("/").getPath();
			System.out.println("输出路径 : " + path);
			ExcelHelper.writeList(path + "test_" + System.currentTimeMillis() + ".xlsx", bookList);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	

@

Java
1
https://gitee.com/hxr521521/easyexcel.git
git@gitee.com:hxr521521/easyexcel.git
hxr521521
easyexcel
easyexcel
master

搜索帮助