- 授权协议: Apache-2.0
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/fartherp/framework
- 软件文档: https://github.com/fartherp/framework/tree/master/framework-poi
- 官方下载: https://github.com/fartherp/framework/releases
软件介绍
poi框架 framework-poi
> 简单、好用且轻量级的海量excel,csv文件导入导出解决方案。解决火狐浏览器中文编码问题。
> 注:excel的合并功能及复杂功能,使用代码实现比较复杂,框架只提供单行的导入导出。
如何使用?
引入Maven依赖或下载jar包
<dependency> <groupId>com.github.fartherp</groupId> <artifactId>framework-poi</artifactId> <version>3.0.4</version> </dependency>
CSV常用例子:
CSVRead.read(CSVReadTest.class.getResourceAsStream("/a.csv"), new CSVReadDeal<CsvReadDto>() {
// 单条数据处理(每一行对应一个javabean)
public CsvReadDto dealBean(String[] arr) {
CsvReadDto dto = new CsvReadDto();
dto.setId(Long.valueOf(arr[0]));
dto.setName(arr[1]);
dto.setAge(Integer.valueOf(arr[2]));
return dto;
}
// 批量数据处理(可以批量入库)
public void dealBatchBean(List<CsvReadDto> list) {
Assert.assertEquals("name1";, list.get(0).getName());
Assert.assertEquals("name2", list.get(1).getName());
Assert.assertEquals("name3", list.get(2).getName());
}
// 批量加载多少数据,统一处理(默认1000)
public int getBatchCount() {
return super.getBatchCount();
}
// 从第几行开始加载(默认跳过第一行)
public int skipLine() {
return super.skipLine();
}
});
2.CSV文件导出:
String filename = "TEST"; String[] title = SheetsTitlesEnum.USER_LOGIN_LOG.getTitle(); List<String[]> bodyList = new ArrayList<>(); CsvUtil.writeCsvFile(filename, title, bodyList);
3.浏览器下载CSV文件:
HttpServletResponse response = null; HttpServletRequest request = null; String filename = "TEST"; String[] title = SheetsTitlesEnum.USER_LOGIN_LOG.getTitle(); List<String[]> bodyList = new ArrayList<>(); CsvUtil.writeCsvFile(response, request, filename, title, bodyList);
Excel常用例子:
1.Excel文件导入:
ExcelRead.read(ExcelReadTest.class.getResourceAsStream("/a.xls"), new ExcelReadDeal<ExcelReadDto>() {
// 单条数据处理(每一行对应一个javabean)
public ExcelReadDto dealBean(Row row) {
ExcelReadDto dto = new ExcelReadDto();
dto.setId(new BigDecimal(row.getCell(0).toString()).longValue());
dto.setName(row.getCell(1).toString());
dto.setAge(Integer.valueOf(row.getCell(2).toString()));
return dto;
}
// 批量数据处理(可以批量入库)
public void dealBatchBean(List<ExcelReadDto> list) {
Assert.assertEquals("name1", list.get(0).getName());
Assert.assertEquals("name2", list.get(1).getName());
Assert.assertEquals("name3", list.get(2).getName());
}
// 批量加载多少数据,统一处理(默认1000)
public int getBatchCount() {
return super.getBatchCount();
}
// 从第几行开始加载(默认跳过第一行)
public int skipLine() {
return super.skipLine();
}
});
2.Excel文件导出:
String[] title = new String [6];
title[0] = "登录时间";
title[1] = "用户名";
title[2] = "访问端";
title[3] = "版本系统";
title[4] = "登录IP";
title[5] = "状态";
String fileName = "D:\\style1.xls";
FileExcelWrite.<ExcelDto>build(title, fileName)
.setLargeDataMode(false)
.deal(obj -> {
String[] result = new String[6];
result[0] = obj.getTime();
result[1] = obj.getName();
result[2] = obj.getClient();
result[3] = obj.getVersion();
result[4] = obj.getIp();
result[5] = obj.getStatus() + "";
return result;
})
.list(ExcelWriteStyleTest.getList())// 默认情况下导出数据达到excel最大行,自动切换sheet,(xlsx=1048576,xls=65536)
.list(ExcelWriteStyleTest.getList1())
.write();
3.Excel文件导出(风格,可以自定义风格):
Map<String, Object> map = new HashMap<>();
map.put("quoteCurrency", "ETH");
map.put("symbol", "USDT_ETH");
map.put("startTime", "2019-01-09 00:00:00");
map.put("endTime", "2019-01-09 12:00:00");
String fileName = "D:\\styleInputStream.xls";
FileExcelWrite.<ExcelDto>build(this.getClass().getResourceAsStream("/c.xls"), fileName)
.additional(map)
.deal(new WriteDeal<ExcelDto>() {
public String[] dealBean(ExcelDto obj) {
String[] result = new String[3];
result[0] = obj.getId() + "";
result[1] = obj.getName();
result[2] = obj.getAge() + "";
return result;
}
public int skipLine() {
return 4;
}
})
.list(getList())
.write();
4.浏览器下载Excel文件:
String[] title = new String [6];
title[0] = "登录时间";
title[1] = "用户名";
title[2] = "访问端";
title[3] = "版本系统";
title[4] = "登录IP";
title[5] = "状态";
String fileName = "D:\\style1.xls";
HttpServletResponseExcelWrite.<ExcelDto>build(title, fileName, request, response)
.setLargeDataMode(false)
.deal(obj -> {
String[] result = new String[6];
result[0] = obj.getTime();
result[1] = obj.getName();
result[2] = obj.getClient();
result[3] = obj.getVersion();
result[4] = obj.getIp();
result[5] = obj.getStatus() + "";
return result;
})
.list(ExcelWriteStyleTest.getList())// 默认情况下导出数据达到excel最大行,自动切换sheet,(xlsx=1048576,xls=65536)
.list(ExcelWriteStyleTest.getList1())
.write();
孵化Twitter
[美]尼克·比尔顿(Nick Bilton) / 欧常智、张宇、单旖 / 浙江人民出版社 / 2014-1 / 49.90元
一个在挣扎中生存的博客平台Odeo,一小撮龙蛇混杂的无政府主义者员工,经历了怎样的涅槃,摇身一变,成为纽交所最闪耀的上市企业Twitter? 一个野心勃勃的农场小男孩,一个满身纹身的“无名氏“,一个爱开玩笑的外交家,一位害羞而又充满活力的极客,这四位各有特色的创始人如何从兢兢业业、每日劳作的工程师,成为了登上杂志封面、奥普拉秀和每日秀的富裕名人?而在Twitter日益茁壮成长的过程中,他们又......一起来看看 《孵化Twitter》 这本书的介绍吧!
