从Java练成我从这里复制的类MysqlToXls
: http://mikescode.wordpress.com/2008/02/16/exporting-a-mysql-table-to-excel-xls-in-java/出口MySQL的数据采用Apache POI
我编辑的类做一个构造函数,不需要任何参数,以这样的方式
public MysqlToXls()
throws ClassNotFoundException, SQLException {
// Create MySQL database connection
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/Spinning?user=root&useUnicode=true&characterEncoding=utf8";
connection = DriverManager.getConnection(url);
}
虽然没有任何指导,我尝试做自己,我无法。
MysqlToXls m=new MysqlToXls();
m.generateXls("utente", "utenti.xls");
但是没有错误,文件utenti.xls保持空白。 有人知道问题在哪里吗?
表'utente'中有任何数据吗? generateXls()中的ResultSet是否包含任何结果? – harpun 2013-02-09 13:01:41
是的,我有数据和rs不是空的。 – Martina 2013-02-09 13:03:24