KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My program successfully creates and fills a Excel(.xls) file. Once created, I would like the new file to open in the system's default program (Excel in my case). How can I achieve this? For an older program where I wanted to open a txt file in Notepad, I used the following: if (!Desktop.isDesktopSupported()) { System.err.println("Desktop not supported"); // use alternative (Runtime.exec) return; } Desktop desktop = Desktop.getDesktop(); if (!desktop.isSupported(Desktop.Action.EDIT)) { System.err.println("EDIT not supported"); // use alternative (Runtime.exec) return; } try { desktop.edit(new File(this.outputFilePath)); } catch (IOException ex) { ex.printStackTrace(); } When I try to use this code for an Excel file it gives me the following error: java.io.IOException: Failed to edit file:C:/foo.xls Suggestions?
Tags (comma-separated)
Save Edits
Cancel