-
Notifications
You must be signed in to change notification settings - Fork 325
FAQ
All versions of myexcel only support jdk8+.
Version 1.4.1 and later, please use AttachmentExportUtil \ FileExportUtil tool class to export, do not care about the suffix and Chinese issues; For other versions, please set the response stream as follows:
response.setCharacterEncoding(CharEncoding.UTF_8);
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CharEncoding.UTF_8));
If the workbooktype is not specified, the default format of the file is. Xlsx, which is also recommended.
Currently, the template engines supported by default include FreeMarker, Beetl, groovy and thymeleaf template engine. When excel is created by the above default excelbuilder, template files can only be placed under classpath, such as resources.
Set Excel sheet name:Add <caption>sheet名称</caption>
to Table
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<table>
<caption>sheet名称</caption>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
Excel version | Maximum number of rows | columns supported |
---|---|---|
Excel 2013 | 1,048,576 | 16,384 |
Excel 2010 | 1,048,576 | 16,384 |
Excel 2007 | 1,048,576 | 16,384 |
Excel 97-2003 | 65,536 | 256 |
The following errors may occur during the concurrent generation of Excel in the lower version of poi:
Caused by: java.io.IOException: Could not create temporary directory '/home/admin/dio2o/.default/temp/poifiles'
at org.apache.poi.util.DefaultTempFileCreationStrategy.createTempDirectory(DefaultTempFileCreationStrategy.java:93) ~[poi-3.15.jar:3.15]
at org.apache.poi.util.DefaultTempFileCreationStrategy.createPOIFilesDirectory(DefaultTempFileCreationStrategy.java:82) ~[poi-3.15.jar:3.15]
The corresponding source code is as follows:
private void createTempDirectory(File directory) throws IOException {
if (!(directory.exists() || directory.mkdirs()) || !directory.isDirectory()) {
throw new IOException("Could not create temporary directory '" + directory + "'");
}
}
The POI version adopted by myexcel has fixed this problem. Please feel free to use it. The modified source code is as follows:
private synchronized void createTempDirectory(File directory) throws IOException {
boolean dirExists = directory.exists() || directory.mkdirs();
if (!dirExists) {
throw new IOException("Could not create temporary directory '" + directory + "'");
} else if (!directory.isDirectory()) {
throw new IOException("Could not create temporary directory. '" + directory + "' exists but is not a directory.");
}
}
For. XLS files, POI predefined 56 colors. If you want to customize colors, you need to cover 56 colors. Currently, the solution is not determined. Therefore, it is recommended that you use. Xlsx for customized colors. If you can only use. XLS files, you can only use 56 predefined colors. For color list, please refer to: color index
Usage mode:
Take HSSFColor. Olive green
as an example. When setting a style, set it to style = "background color: olivegreen"
.
Using the readthen interface in some scenarios will result in the following error prompt:
Error:(210, 62) java: ambiguous reference to readthen
com.github.liaochong.myexcel.core.DefaultExcelReader->
readThen(java.io.InputStream,java.util.function.Consumer<T>) with com.github.liaochong.myexcel.core.DefaultExcelReader-> readThen(java.io.InputStream,java.util.function.Function<T,java.lang.Boolean>) all match
To solve this problem, add braces in the method body "{",as follows:
readThen(file,data->{System.out.println(data.name);})
Postman test download, you need to select 'send and download'. Otherwise, the following exceptions may occur:
java.lang.RuntimeException: java.io.IOException: This archive contains unclosed entries.
When using saxexcelreader to read excel, the original value of 9.5 may appear, and the imported value will become 9.50000000007. The problem is that the actual storage of Excel is 9.50000000007. For non program reasons, to solve the problem, you can use the text function, change the value to text, and remember that you can't simply set the cell to text. This method can't change the cell in practice format.
When using FreemarkerExcelBuilder
to export excel, if there is a large value output greater than 1000, there may be the following errors:
Actual value: 1018,280029687 Result after rendering: 1 01828
You can use ${x?c}
to solve this problem.
-
Overview
概述 -
FAQ
常见问题 -
Dependency adding
依赖添加 -
Excel/Csv import
Excel/Csv导入 - 一对多导入
-
Excel default export
默认导出 -
Excel streaming export
流式导出 -
Dynamic export
动态导出 -
Excel template build
模板构建 -
CSV export
csv导出 -
Multiple sheet import
多sheet导入 -
Multiple sheet export
多sheet导出 - 聚合列&聚合导出
-
Custom style
自定义样式 -
Multilevel header
多级表头 -
Wrap within cell
单元格内换行 -
Image export
图片导出 -
Image import
图片导入 -
Hyperlink
链接 - 读取链接
-
Template row height setting
模板行高度设置 -
Drop-down-list
下拉列表 -
Custom convert
写入自定义转化 -
Formula usage
公式使用 -
Template cell setting
单元格设置 -
Header freeze
区域冻结 - 提示
-
Style support
样式支持 - 添加水印
- 按列读取
- 单元格斜线绘制
- 设置批注
- 版本日志