MyExcel, is a set of import, export, encryption, Excel and many other features of Java toolkit.
- Import : Provides simple API, read the contents of Excel, and converted to List <Bean>.
- Export : fast mass data derived a simple list, may be generated high complexity Excel layouts, layout refers complex comprising a plurality of irregular merged cells, background color, font size, italics, drop-down lists, etc., can be automatically divides Excel generating a zip archive.
With nearly two months to reconstruct, MyExcel 3.0.0.RC version released today use this point to modify the following overview:
- Repair DefaultExcelBuilder, DefaultStreamExcelBuilder custom style invalidity;
- Fix problems with reading decimal integer error;
- Repair DefaultStreamExcelBuilder massive data export multi-page sheet, can not fix all the problems header row;
- Repair DefaultStreamExcelBuilder writing reset workbook type error;
- Based DefaultStreamExcelBuilder rewrite DefaultExcelBuilder, in the case of guarantee simple and convenient API, to solve the root causes of performance problems;
- New DefaultExcelBuilder, DefaultStreamExcelBuilder support export images;
- New DefaultExcelBuilder, DefaultStreamExcelBuilder support global style settings, interlaced style settings;
- New DefaultExcelBuilder, DefaultStreamExcelBuilder, template ExcelBuilder support custom row heights;
- New DefaultStreamExcelBuilder new cancel, clear interfaces, enhanced resource initiative to clean up capacity;
- Add the ExcelBuilder unit test project to enhance the stability;
- When you add an exception to read, the contents of the relevant row and tips to speed up the issue positioning speed;
- Delete rowAccessWindowSize option, the default best practices, but also to avoid user errors are not familiar with the use of lead, not backward compatible;
- Modify autoWidthStrategy method widthStrategy method, strengthen the interface semantics;
- The original DefaultStreamExcelBuilder start (int waitQueueSize, Class [] groups) option parameter to the method, waitQueueSize (), groups ();
- Support with the same file name when writing and writing;
- Reconstruction SaxExcelReader, enhance code readability;
- CsvBuilder append new feature allows the generated file additional data;
- DefaultStreamExcelBuilder time processing class cache increases, deriving further improve performance;
Note that, due to the large area of reconstruction, resulting in a part of the API is not compatible 3.0.0.RC the following versions:
- Delete rowAccessWindowSize options;
- The original DefaultStreamExcelBuilder start (int waitQueueSize, Class [] groups) option parameter to the method, waitQueueSize (), groups ();
// 新设定分组、等待队列容量方式
DefaultStreamExcelBuilder excelBuilder = DefaultStreamExcelBuilder.of(CommonPeople.class)
.start(100,CommonPeople.class);
// 新设定分组、等待队列容量方式
DefaultStreamExcelBuilder excelBuilder = DefaultStreamExcelBuilder.of(CommonPeople.class)
.groups(CommonPeople.class)
.waitQueueSize(100)
.start();
DETAILED update points as follows:
1. Add additional data csv way
CsvBuilder<CsvPeople> csvBuilder = CsvBuilder.of(People.class);
for (int i = 0; i < 10; i++) {
csvBuilder.append(data(1000));
}
Csv csv = csvBuilder.build();
AttachmentExportUtil.export(csv.getFilePath(), "test.csv", response);
// 该种方式会覆盖原append.csv文件
csv.write(Paths.get("/User/append.csv"));
// 该种方式会在原append.csv文件继续追加数据,而不是覆盖
csv.write(Paths.get("/User/append.csv"),true);
2. Customize the height (Bean form)
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@ExcelTable(sheetName = "人员信息", rowHeight = 50)
public class CommonPeople {
@ExcelColumn(title = "姓名", index = 0)
String name;
@ExcelColumn(title = "年龄", index = 1)
Integer age;
@ExcelColumn(title = "是否会跳舞", groups = CommonPeople.class, index = 2)
boolean dance;
@ExcelColumn(title = "金钱", decimalFormat = "#,000.00", index = 3)
BigDecimal money;
}
RowHeight can be set.
3. Customize the height (template mode)
<% DIRECTIVE SAFE_OUTPUT_OPEN; %>
<table>
<caption>${sheetName}</caption>
<thead>
<tr style="background-color: #6495ED">
<th colspan="3" style="text-align: center;vertical-align: middle;font-weight: bold;font-size: 14px;">产品介绍</th>
</tr>
<tr>
<% for(title in titles){ %>
<th>${title}</th>
<% } %>
</tr>
</thead>
<% if(data!=null){ %>
<tbody>
<% for(item in data){ %>
<tr style="height: 100px;">
<td>${item.category}</td>
<td>${item.name}</td>
<td>${item.count}</td>
</tr>
<% } %>
</tbody>
<% } %>
</table>
<%
//关闭安全输出。
DIRECTIVE SAFE_OUTPUT_CLOSE;
%>
Set height Style style = "height: 100px;" can be.
4. interlace pattern set
@ExcelColumn(order = 0, title = "姓名",style = {"title->color:red;","even->color:yellow;","odd->background-color:green;width:50"})
private String name;
odd, even rows corresponding to the parity pattern.
The rest, please move the document: https://github.com/liaochong/myexcel/wiki
Welcome everyone to use, any questions can be raised through github issue, will try to respond promptly! ! !