1. 程式人生 > >解決OpenOffice檔案預覽轉換xlsx檔案出現com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported

解決OpenOffice檔案預覽轉換xlsx檔案出現com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported

OpenOffice在進行xlsx檔案預覽時出現發生如下錯誤:

com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:335)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:304)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactoryH

andler.request(ProxyFactory.java:151)atcom.sun.star.lib.uno.bridges.javaremote.ProxyFactoryHandler.request(ProxyFactory.java:151) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactoryHandler.invoke(ProxyFactory.java:133)
at com.sun.proxy.$Proxy71.loadComponentFromURL(Unknown Source)
at org.artofsolving.jodconverter.AbstractConversionTask.loadDocument(AbstractConversionTask.java:84)
at org.artofsolving.jodconverter.AbstractConversionTask.execute(AbstractConversionTask.java:53)
at org.artofsolving.jodconverter.office.PooledOfficeManager2.
run(PooledOfficeManager.java:75)atjava.util.concurrent.Executors2.run(PooledOfficeManager.java:75) at java.util.concurrent.Executors
RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

由於xlsx字尾不在檔案裝換的支援的範圍內,所以在裝換的過程中出現了檔案找不到的錯誤,解決方法如下,繼承DocumentFormatRegistry,重寫getFormatByExtension進行字尾匹配方法,將字尾名包括xls時,將其匹配到xls
在這裡插入圖片描述