Can someone point me to some good tutorials开发者_StackOverflow中文版 for generating a resultset into a CSV or even Excel file?
I'm using j2ee, with Spring and Hibernate.
Here is a utility that does CSV reading and writing:
http://opencsv.sourceforge.net/
can someone point me to some good tutorials for generating a resultset into a csv
It's extremely straightforward to roll your own — just make sure to use StringBuilder
or Joiner
. Or, use a library.
or even excel file.
You'll want to use Apache POI for that.
Use opencsv 2.2.jar
http://opencsv.sourceforge.net/
CSVWriter writer = new CSVWriter(new FileWriter("yourfile.csv"), '\t'); // feed in your array (or convert your data to an array) String[] entries = "first#second#third".split("#"); writer.writeNext(entries); writer.close();
精彩评论