Opening an Excel file using the default program

左心房为你撑大大i 提交于 2019-11-27 21:31:36

Try to use Desktop.open() instead of Desktop.edit() :

Desktop dt = Desktop.getDesktop();
dt.open(new File(this.outputFilePath));

If Desktop.open() is not available then the Windows file association can be used :

Process p = 
  Runtime.getRuntime()
   .exec("rundll32 url.dll,FileProtocolHandler " + this.outputFilePath);

You probably did the Runtime.exec incorrectly. Give this a look to see if that's the case.

If you just want to open an Excel file with Java, I'd recommend using Andy Khan's JExcel API. Perhaps using that with a Swing JTable will be just the ticket.

The most simple and efficient way.

Desktop.getDesktop().open(new File("inputFilePath"));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!