I have a table of data and i wanted an export function, this application run on web so i want to create a csv file and then offer (open or save as option) usual download options. Im using CSV writer at the moment.
The line in question here is Runtime.getRuntime().exec("export.csv");
give error listed at bottom
How would i do this?
Here is the action tied to a button
Action exportData = new Action() {
private static final long serialVersionUID = -7803023178172634837L;
@Override
public void execute(UIContext uic, ActionEvent event) {
try{
CSVWriter writer = new CSVWriter(new FileWriter("export.csv"), '\t');
int i = 0;
while (i < forExport.getTotalCount()){
String[] entries = {
forExport.getSearchResults().get(i).getName().getGivenNames() + forExport.getSearchResults().get(i).getName().getSurname(),
forExport.getSearchResults().get(i).getId()
};
writer.writeNext(entries);
i++;
}
writer.close();
Runtime.getRuntime().exec("export.csv");
}catch(Exception e){
system.out.print(e);
}
}
};
getting error java.io.IOException: Cannot run program "export.csv": CreateProcess error=193, %1 is not a valid Win32 applicationDEBUG
NOTE: i do not want it to automatically open in excel, i want the option to save or open.