当前位置:网站首页>Easyexcl export 1million lines of EXECL report font error solution
Easyexcl export 1million lines of EXECL report font error solution
2022-06-29 09:29:00 【MonkeyKing_ sunyuhua】
Use easyexecl do 100 Line ten thousand csv Export of , Two errors will be reported , It's all because of openjdk Compact install to docker Inside , The problem of missing Fonts .
Error details :
/usr/local/openjdk-17/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
2022-06-24 14:39:00.045 INFO 1 --- [nio-5010-exec-2] c.f.b.b.c.BillingDetailController : export execl1656081540043
2022-06-24 14:39:05.980 ERROR 1 --- [nio-5010-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.alibaba.excel.exception.ExcelGenerateException: java.lang.UnsatisfiedLinkError: /usr/local/openjdk-17/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory] with root cause
java.lang.UnsatisfiedLinkError: /usr/local/openjdk-17/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method) ~[na:na]
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388) ~[na:na]
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232) ~[na:na]
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174) ~[na:na]
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:315) ~[na:na]
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:285) ~[na:na]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398) ~[na:na]
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818) ~[na:na]
at java.base/java.lang.System.loadLibrary(System.java:1989) ~[na:na]
at java.desktop/sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:58) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
at java.desktop/sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:33) ~[na:na]
at java.desktop/sun.font.SunFontManager$1.run(SunFontManager.java:275) ~[na:na]
at java.desktop/sun.font.SunFontManager$1.run(SunFontManager.java:273) ~[na:na]
at java.base/java.security.AccessControlle
perhaps
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
nerateException: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager] with root cause
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:467) ~[na:na]
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75) ~[na:na]
at java.desktop/java.awt.Font.getFont2D(Font.java:526) ~[na:na]
at java.desktop/java.awt.Font.canDisplayUpTo(Font.java:2282) ~[na:na]
at java.desktop/java.awt.font.TextLayout.singleFont(TextLayout.java:469) ~[na:na]
at java.desktop/java.awt.font.TextLayout.<init>(TextLayout.java:530) ~[na:na]
at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:273) ~[poi-4.1.2.jar:4.1.2]
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117) ~[poi-ooxml-4.1.2.jar:4.1.2]
at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82) ~[poi-ooxml-4.1.2.jar:4.1.2]
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:684) ~[poi-ooxml-4.1.2.jar:4.1.2]
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:705) ~[poi-ooxml-4.1.2.jar:4.1.2]
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:88) ~[poi-ooxml-4.1.2.jar:4.1.2]
at com.alibaba.excel.util.WorkBookUtil.createSheet(WorkBookUtil.java:84) ~[easyexcel-core-3.1.1.jar:na]
at com.alibaba.excel.context.WriteContextImpl.createSheet(WriteContextImpl.java:223) ~[easyexcel-core-3.1.1.jar:na]
at com.alibaba.excel.context.WriteContextImpl.initSheet(WriteContextImpl.java:182) ~[easyexcel-core-3.1.1.jar:na]
at com.alibaba.excel.context.WriteContextImpl.currentSheet(WriteContextImpl.java:135) ~[easyexcel-core-3.1.1.ja
A new image is needed , With openjdk17 For example
1、 edit dockerfile file
FROM openjdk:17-alpine
# solve easyExcel Export missing Fonts bug
RUN apk add --update ttf-dejavu fontconfig && rm -rf /var/cache/apk/*
2、IDEA To configure docker plug-in unit
The installation steps can be done by yourself google once 

3、 install Docker Desktop
Install the configuration and its registration , Sure google Inquire about 

4、 function dockerfile



5、 Push and view docker-hub Whether there is , Be sure to type in your own user name tag, Otherwise, the push will fail


6 、 Log in to the server that needs this image , Pull down or configure the image gradle Automatically pull the image

Or configure the dependent image 
7、 Re deploy the application , Restart , That is not an error

Note appended :esayExcel Export code for
/**
* export excel
*/
@RequestMapping("/xxxexportcsv100")
fun export(response: HttpServletResponse) {
val startTime = System.currentTimeMillis()
logger.info(" export execl$startTime")
val outputStream: OutputStream = response.outputStream
val time = SimpleDateFormat("yyyy-MM-dd-hh-mm-ss").format(Date())
response.setHeader("Content-disposition", "attachment; filename=contract$time.xlsx")
response.contentType = "application/octet-stream;charset=UTF-8"
response.setHeader("Pragma", "No-cache")
response.setHeader("Cache-Control", "no-cache")
response.setDateHeader("Expires", 0)
val count: Int = billingDetailService.countByIdIsNotNull()
// If the total amount of data is redundant 10 ten thousand , Paging export
if (count > 100000) {
// How many per page
val max = 100000
// Must be placed outside the loop , Otherwise, it will be new
val excelWriter: ExcelWriter = EasyExcel.write(outputStream).build()
for (i in 0 until count / max + 1) {
val exportList: List<BillingDetailResourceDto> = billingDetailService.findAllBySize(i, max)
val writeSheet: WriteSheet =
EasyExcel.writerSheet(i, " bill " + (i + 1)).head(BillingDetailResourceDto::class.java)
.registerWriteHandler(LongestMatchColumnWidthStyleStrategy()).build()
excelWriter.write(exportList, writeSheet)
logger.info("100000 That's ok ===${System.currentTimeMillis()}")
}
// Refresh stream
excelWriter.finish()
} else {
val exportList: List<BillingDetailResourceDto> = billingDetailService.findAllBySize(0, count)
EasyExcel.write(outputStream, BillingDetailResourceDto::class.java)
.registerWriteHandler(LongestMatchColumnWidthStyleStrategy()).sheet(" bill ").doWrite(exportList)
}
outputStream.flush()
response.outputStream.close()
val endTime = System.currentTimeMillis()
logger.info(" export execl end $endTime== Time consuming =${endTime - startTime}")
}
边栏推荐
- UE4 display 3D editable points in Viewport
- 微信小程序子组件向页面传值(父子组件间的通信)带源码
- pytorch总结学习系列-广播机制
- MySQL uses union all to count the total number of combinations of multiple tables and the number of tables respectively
- GPU训练云平台记录
- LFFD:一种用于边缘检测的轻量化快速人脸检测器
- ISO16000-9建筑产品和家具中挥发性有机物的测试
- promise方法的简单使用
- Wechat applet latest canvas2d handwritten signature
- The former security director of Uber faced fraud allegations and concealed the data leakage event
猜你喜欢

UE4 remove the mask transparent white edge in the material

Pytorch Summary - Automatic gradient

YOLACT实时实例分割

promise方法的简单使用

Difference between factory mode and strategy mode

Record the field name dynamically modified by SetData of wechat applet

GD32F4xx 以太網芯片(enc28j60)驅動移植

Mongodb persistence

数据处理时代,数据质量建设才是企业的生存之道

3DMax 卡死、白屏、渲染死机问题总结
随机推荐
基于区域注意的通用目标检测
网络安全问题
AugFPN:改进多尺度特征学习用于目标检测
Chapter 12 signals (II) - examples of producers and consumers
UE4 VS的Visual Assist插件设置
微信小程序项目:微信小程序页面布局
Wechat applet search keyword highlighting and ctrl+f search positioning
UE4 去掉材质中Mask透明白边
Can we trust bounding box annotations for object detection
使用GPU训练kernel切换
SSD Improvement cfenet
promise方法的简单使用
数据处理时代,数据质量建设才是企业的生存之道
Redo after JS rotation view (longer full version, can be run)
Pytoch Summary - transform between sensor and numpy
Wechat applet wx Navigateback returns the parameters carried on the previous page
Mysql database and table splitting strategy and application scenarios
Wechat applet sharing page, sharing to the circle of friends
Recursive RBAC menu level display infinite classification
Wechat applet project: tab navigation bar