MyExcel is a set of import, export, encryption, Excel and many other features of Java toolkit.
This update is mainly BUG repair, update points are as follows:
- Additional data sheet repair is empty lead to additional failures;
- Additional sheet repair failures due to the original configuration;
- Static field repair using @ExcelTable caused by export issues, default static fields are not exported, it can also be canceled by ignoreStaticFields = false;
- Modify the use of the same class type, sheet name can not be self-growth problem;
- Select Auto repair column width to the wrong question;
- Repair setting does not take effect workbook some cases the type of problem;
- Repair DefaultStreamExcelBuilder title line can not be fixed the problem directly;
- New DefaultExcelBuilder \ DefaultStreamExcelBuilder wrap, the default is true, can be canceled by @ExcelTable in wrapText;
- Modify DefaultExcelBuilder \ DefaultStreamExcelBuilder partial data structure LinkedList, to reduce memory requirements;
- Rapid removal modify data logic, to enhance the efficiency of data processing;
- Optimizing section switching operation, copy the entire data list to avoid the sea;
We recommend that all users upgrade as soon as possible to use, more venue: https://github.com/liaochong/myexcel/wiki
--------------------------------------------------------------------------------------
Advantages | Advantages
- Complex may be generated in any form : This tool uses an iterative manner Excel rendering cells, can generate arbitrary complexity Excel, a variety of strategies width;
- Zero learning costs : Html use as a template, learning cost is almost zero;
- Support for common background color, borders, fonts, and other style settings : specific see below Style-support (style support) section;
- Support for .XLS, .XLSX : support for generating .xls, .xlsx extension of Excel;
- Support formula is derived : support setting a formula in Excel template, reducing the amount of computation server-side;
- SXSSF low memory mode supports : low-memory support SXSSF mode may be utilized to generate low memory .xlsx;
- Support for producer-consumer model export : Support for producer-consumer model exported without a one-time all the data, batch data acquisition mode with SXSSF real significance Shanghai amount of data export;
- Support a variety of template engine : is built Freemarker, Groovy, Beetl, Thymeleaf other commonly used Excel template engine builder (For details, see documents the Getting Started ), recommended Beetl template engine ( Beetl document );
- Excel provides a default constructor, direct output simple Excel : without writing any Html, has built a default template, can be output directly from the POJO data list;
- Generate support for a multi-sheet : to table a sheet unit, to support a multi-sheet Excel document export;
Import example:
URL htmlToExcelEampleURL = this.getClass().getResource("/templates/read_example.xlsx");
Path path = Paths.get(htmlToExcelEampleURL.toURI());
// 方式一:全部读取后处理
List<ArtCrowd> result = DefaultExcelReader.of(ArtCrowd.class)
.sheet(0) // 0代表第一个,如果为0,可省略该操作
.rowFilter(row -> row.getRowNum() > 0) // 如无需过滤,可省略该操作,0代表第一行
.beanFilter(ArtCrowd::isDance) // bean过滤
.read(path.toFile());// 可接收inputStream
Export Example:
/**
* 普通方式导出
*/
@GetMapping("/default/excel/example")
public void defaultBuild(HttpServletResponse response) throws Exception {
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
AttachmentExportUtil.export(workbook, "艺术生信息", response);
// 加密导出 AttachmentExportUtil.encryptExport(workbook, "艺术生信息", response,"123456");
}
effect: