Use Open CSV to export the data.
Here I have given download option for the whole table.
I am getting the whole table data as a list.And making csv values and storing in csv file.
public void exportEvent(ActionRequest actionRequest,ActionResponse actionResponse) throws SystemException, IOException{
List<stuadmission> admissions = stuadmissionLocalServiceUtil.g etstuadmissions(-1, -1);
CSVWriter writer = new CSVWriter(new FileWriter("/home/filename.csv"), '\t');
for (stuadmission student : admissions){
String str = Integer.toString(student.getAd missionno());
String str2 = str + ","+ student.getBatch();
String[] strings = str2.split(",");
writer.writeNext(strings);
writer.close();}
}
List<stuadmission> admissions = stuadmissionLocalServiceUtil.g
CSVWriter writer = new CSVWriter(new FileWriter("/home/filename.csv"), '\t');
for (stuadmission student : admissions){
String str = Integer.toString(student.getAd
String str2 = str + ","+ student.getBatch();
String[] strings = str2.split(",");
writer.writeNext(strings);
writer.close();}
}
0 comments:
Post a Comment