我有这个 DAO..
public class AreaDAO {
private Database database;
public AreaDAO(Database database) {
this.database = database;
}
public List<Area> list() throws SQLException {
Connection connection = null;
PreparedStatement statement = null;
ResultSet resultSet = null;
List<Area> areas = new ArrayList<Area>();
try {
connection = database.getConnection();
statement = connection.prepareStatement("select distinct img_hub, country from ifs_db limit 50");
resultSet = statement.executeQuery();
while (resultSet.next()) {
Area area = new Area();
area.setImg_hub(resultSet.getString("img_hub"));
area.setCountry(resultSet.getString("country"));
areas.add(area);
}
} finally {
if (resultSet != null) try { resultSet.close(); } catch (SQLException logOrIgnore) {}
if (statement != null) try { statement.close(); } catch (SQLException logOrIgnore) {}
if (connection != null) try { connection.close(); } catch (SQLException logOrIgnore) {}
}
return areas;
}
}
这会产生一个数据列表......
如何让用户只需单击链接即可下载excel中的所有数据..
我研究了我们并发现了这个......(BalusC)
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=name.xls");
WritableWorkbook workBook = Workbook.createWorkbook(response.getOutputStream());
我把它放在我的 servlet 中,我怎么只是得到一个空白的工作表......我怎么能使用它,这样我就可以让用户下载一个