有这段代码可以打开文件:
Runtime.getRuntime().exec(new String[]
{"rundll32", "url.dll,FileProtocolHandler",
file.getAbsolutePath()});
我在哪里传递了文件。奇怪的是,它没有在 xlsx 中打开一些自动生成的文件,因为它能够打开其他 xlsx 文件。无法调试/找到解决方案,请帮助
有这段代码可以打开文件:
Runtime.getRuntime().exec(new String[]
{"rundll32", "url.dll,FileProtocolHandler",
file.getAbsolutePath()});
我在哪里传递了文件。奇怪的是,它没有在 xlsx 中打开一些自动生成的文件,因为它能够打开其他 xlsx 文件。无法调试/找到解决方案,请帮助
您可以尝试以下方法:
try {
Desktop.getDesktop().open(new File("F:\\folder\\data\\file.xlsx"));
} catch (IOException e) {e.printStackTrace();}
您可以使用新的 Apache API 打开和访问所有 excel 文件数据,而不是使用 DLL 方法读取 xls。
请查看以下链接了解更多详情: https ://poi.apache.org/