为有中文需求的客户提供多渠道中文技术支持.

Fri Dec 30, 2022 3:16 am

在excel中生成图表,将sheet页转化为图片使用Worksheet.toImage()方法时,出现错误:
java.lang.InternalError: Odd number of new curves!
at sun.awt.geom.AreaOp.resolveLinks(AreaOp.java:450) ~[na:1.8.0_171]
at sun.awt.geom.AreaOp.pruneEdges(AreaOp.java:392) ~[na:1.8.0_171]
at sun.awt.geom.AreaOp.calculate(AreaOp.java:159) ~[na:1.8.0_171]
at java.awt.geom.Area.pathToCurves(Area.java:195) ~[na:1.8.0_171]
at java.awt.geom.Area.<init>(Area.java:126) ~[na:1.8.0_171]
at com.spire.xls.packages.sprCnc.createStrokedShape(jhd:279) ~[spire.xls.free-5.1.0.jar:5.1.0]
at sun.java2d.pipe.AAShapePipe.draw(AAShapePipe.java:60) ~[na:1.8.0_171]
at sun.java2d.pipe.PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:148) ~[na:1.8.0_171]
at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:154) ~[na:1.8.0_171]
at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2497) ~[na:1.8.0_171]
at com.spire.xls.packages.sprZSC.spr (umg:726) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprZSC.spr (umg:596) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprZSC.spr (umg:201) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprZSC.spr (umg:5303) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprofB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.spruAB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprkbB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprkbB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprkbB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprkbB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprkbB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprpQA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprSPA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprMPA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprofB.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprHPA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprHPA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.packages.sprVpA.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.core.spreadsheet.XlsWorksheet.spr (Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]
at com.spire.xls.core.spreadsheet.XlsWorksheet.toImage(Unknown Source) ~[spire.xls.free-5.1.0.jar:5.1.0]

Desimasen
 
Posts: 3
Joined: Fri Dec 30, 2022 3:12 am

Fri Dec 30, 2022 5:52 am

您好,

感谢您的留言。
根据您的异常信息来看,您正在使用我们的免费版的Spire.Xls。我这边建议您先使用我们最新的商业版Spire.Xls 12.11.8来再测试您的场景,因为商业版比起免费版更加稳定且修复了更多bug。如果更新到最新的商业版后,此问题还是存在,请提供以下信息。感谢您的援助。

1) 您的原始Excel文档,您可以将它附加在此贴中,也可以通过邮箱(support@e-iceblue.com)发送给我们。
2) 可以复现您问题的完整代码。
3) 您的Jdk版本信息,如Oracle Jdk1.8.
4) 您的测试环境,如win10-64位。

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 915
Joined: Tue Mar 08, 2022 2:02 am

Fri Dec 30, 2022 6:52 am

我试用了12.11.8后仍然出现这个问题
Still inside at end of active edge list!
num curves = 3
num links = 1
y top = 112.75
no more curves
Edge[Curve[3, (88.66667175292969, 112.75), (87.16667175292969, 113.75), (87.16667175292969, 114.75), (88.66667175292969, 115.75), D], L, I]
Edge[Curve[1, (88.66667175292969, 115.75), (88.66667175292969, 112.75), U], L, N]
was equal to 1...
Edge[Curve[1, (88.66667175292969, 115.75), (88.66667175292969, 112.75), U], L, N]
was equal to 1...
2022-12-30 14:36:08.548 ERROR 9560 --- [nio-8585-exec-5] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/sws-rpt] threw exception [Handler dispatch failed; nested exception is java.lang.InternalError: Odd number of new curves!] with root cause

java.lang.InternalError: Odd number of new curves!
at sun.awt.geom.AreaOp.resolveLinks(AreaOp.java:450) ~[na:1.8.0_171]
at sun.awt.geom.AreaOp.pruneEdges(AreaOp.java:392) ~[na:1.8.0_171]
at sun.awt.geom.AreaOp.calculate(AreaOp.java:159) ~[na:1.8.0_171]
at java.awt.geom.Area.pathToCurves(Area.java:195) ~[na:1.8.0_171]
at java.awt.geom.Area.<init>(Area.java:126) ~[na:1.8.0_171]
at com.spire.xls.packages.sprbyv.createStrokedShape(AdvancedStroke.java:290) ~[spire.xls-12.11.8.jar:12.11.8]
at sun.java2d.pipe.AAShapePipe.draw(AAShapePipe.java:60) ~[na:1.8.0_171]
at sun.java2d.pipe.PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:148) ~[na:1.8.0_171]
at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:154) ~[na:1.8.0_171]
at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2497) ~[na:1.8.0_171]
at com.spire.xls.packages.spreiba.spr┹┗—(RasterGraphics.java:350) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.spreiba.spr‣┖—(RasterGraphics.java:647) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.spreiba.spr└┖—(RasterGraphics.java:211) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.spreiba.spr℠™(RasterGraphics.java:3625) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprkaq.spr∫┪(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprbwp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprvnp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprvnp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprvnp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprvnp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprvnp.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprobk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprydk.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprayj.spr※╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprkaq.spr╁⅚(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sproij.spr┃╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sproij.spr▤╃(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.packages.sprkjj.spr‱╄(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr⅛≇(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr┕⌨(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.core.spreadsheet.XlsWorksheet.spr╁╇(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
at com.spire.xls.core.spreadsheet.XlsWorksheet.saveToImage(Unknown Source) ~[spire.xls-12.11.8.jar:12.11.8]
由于内容涉及公司机密,我对文件中出现的名称与数据值做出了修改。
完整代码也因保密原因无法提供,具体调用代码是:
Worksheet ws=worksheets.get(i);
sheetNames.add(ws.getName());
BufferedImage bufferedImage1 = ws.saveToImage(1, 1, ws.getLastRow()+1, ws.getLastColumn()+1);
File fileImg = new File(ClassUtils.getDefaultClassLoader().getResource("").getPath()+"static\\picture\\" +time+"aaa"+i+".png");
pictureNames.add(time+"aaa"+i+".png");
ImageIO.write(bufferedImage1, "PNG", fileImg);
JDK信息为
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.302-b08, mixed mode)
环境为win10-64bit

Desimasen
 
Posts: 3
Joined: Fri Dec 30, 2022 3:12 am

Fri Dec 30, 2022 7:56 am

您好,

感谢您的反馈。
我这边使用Spire.Xls 12.11.8和免费版的Spire.Xls 5.1.0在jdk1.8的环境下测试您提供的文档,我这边都是可以正常产生结果图片的(如下截图)。请问对于这个您修改后的文档,您那边测试有问题吗?我的测试代码如下:

Code: Select all
Workbook workbook =new Workbook();
workbook.loadFromFile("data/20221230023608.xlsx");
Worksheet ws = workbook.getWorksheets().get(0);
//sheetNames.add(ws.getName());
BufferedImage bufferedImage1 = ws.saveToImage(1, 1, ws.getLastRow()+1, ws.getLastColumn()+1);
ImageIO.write(bufferedImage1,"PNG",new File("output/ToImageWithComments_free_5_1_0.png"));


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 915
Joined: Tue Mar 08, 2022 2:02 am

Fri Dec 30, 2022 9:05 am

抱歉之前没有测试修改后的文件。我重新修改了一份文件并测试确认会出现错误。
主要是由于Excel中的图例名称。

Desimasen
 
Posts: 3
Joined: Fri Dec 30, 2022 3:12 am

Fri Dec 30, 2022 9:57 am

您好,

感谢您的反馈。
对于您提供的新文档,我这边使用Spire.Xls 12.11.8测试还是没有重现到您的问题,我将我的测试项目上传到我们的服务器以便您参考,请从下面的链接下载:
https://www.e-iceblue.com/downloads/dem ... e31919.zip

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 915
Joined: Tue Mar 08, 2022 2:02 am

Return to 中文技术支持