I have a database containing one table, i want to generate CSV file with values of this table.
Actually, I want to email this CSV file as an attachment. I know about
Adding to @Cocos2dx answer:
When querying from db you may have null fields, in my case i use a Controller to fetch the data in an object list, but either if you don`t you should check for null or empty values and proper format them (or they can make your table look weird):
String[] details = {
replaceNull(someObject.getId()),
replaceNull(someObject.getName())
};
public static String replaceNull(String input) {
return ((input == null || input.isEmpty()) ? " " : input);
}
writer.writeNext(details);