The result is test on JDK 17.
We just want to locate the root cause of the exception. The exception is due to the environment on your side.
Please share us some time to evaluate it.
The result is test on JDK 17.
We just want to locate the root cause of the exception. The exception is due to the environment on your side.
Please share us some time to evaluate it.
sure thanks. Also can you please suggest if any alternate for CellsHelper.mergeFiles so as to avoid zipfile call and its exception
@rselvarajan
For xlsx file, in fact it is zip file that contains all required data. To load such kind of file, zip api is essential. So it is used not only for CellsHelper.mergerFiles(), but also for all initialization of workbook from OOXML template files.
For old versions such as 20.9.8 you are using, we use java’s zip apis to load the template file. For recent versions, we use our own implementation of zip apis. Our implementation solves some issues of java’s zip util that cause exception for some zip archives. So we recommend to try our recent versions to check whether your issue can be solved.
By the way, for old versions such as 20.9.8, we provide one option to use Apache’s zip instead of Java’s zip. You may put the jar of apache zip util into your classpath and then use the JVM option:
-DAspose.Cells.ZipTool=APACHE
to check whether it can solve your issue.
sure i will try and get back on this
@rselvarajan
Please take your time to try the suggested solutions. Hopefully, your issue will be sorted out. Please let us know your feedback.
Tested on a Ubuntu 24.04 vm with JDK 17. The origin environment var is LANG=en_US.UTF-8
. The origin returned charset is US-UTF8. Both java.util.zip.ZipFile(String name)
and CellsHelper.mergeFiles(new String[]{"Berichtsübersicht.xlsx","Berichtsübersicht2.xlsx"},null,"combined.xlsx");
works OK.
After setting environment var export LANG=C
, the returned charset changed to US-ASCII. I logged the following three items, all of them returned US-ASCII.
System.getProperty("native.encoding");
System.getProperty("sun.jnu.encoding");
java.nio.charset.Charset.defaultCharset();
The code CellsHelper.mergeFiles(new String[]{"Berichtsübersicht.xlsx","Berichtsübersicht2.xlsx"},null,"combined.xlsx");
threw a different exception with yours:
Exception in thread "main" java.io.FileNotFoundException: Can't find file: Berichts?bersicht.xlsx.
at com.aspose.cells.b.a.d.ze.a(Unknown Source)
at com.aspose.cells.b.a.d.ze.<init>(Unknown Source)
at com.aspose.cells.b.a.d.zd.a(Unknown Source)
at com.aspose.cells.FileFormatUtil.detectFileFormat(Unknown Source)
at com.aspose.cells.CellsHelper.mergeFiles(Unknown Source)
However, java.util.zip.ZipFile(String name)
threw a similar exception as yours:
Exception in thread "main" java.io.IOException: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: Berichts?bersicht.xlsx
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1435)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:717)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:251)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:180)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:151)
at Test.main(Test.java:25)
Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: Berichts?bersicht.xlsx
at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:121)
at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:68)
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1432)
... 5 more
At the last, I set environment var back to export LANG=en_US.UTF-8
, everything works OK again.
In my opinion, you may need to configure your environment settings to make returned charset to be US-UTF8. It is hard to us to get a same environment as yours. If possible, you can create a sample Dockerfile to simulate your environment, then we can get the same environment with the Dockerfile.
-DAspose.Cells.ZipTool=APACHE
I will test and get back if any. Really thanks a lot for quick solutions and responses. Appreciate it.
You’re welcome. It’s good to know that the recommended option meets your requirements. Please don’t hesitate to reach out to us if you have any more questions or feedback.