我有從數據庫中獲取數據的默認表模型,我想以doc表格的形式在doc字中打印。如何實現這一點。請參見下面的代碼:用Java創建Word文檔
try {
try {
con = connCC.getDBconnection();
} catch (ClassNotFoundException ex) {
Logger.getLogger(CustomerSR.class.getName()).log(Level.SEVERE, null, ex);
}
stm = con.createStatement();
ResultSet rs = stm.executeQuery("Select * From Appointment");
while (rs.next()) {
for (int col = 0; col < 1; col++) {
rowData.add(rs.getString(1));
rowData.add(rs.getString(2));
rowData.add(rs.getString(3));
rowData.add(rs.getString(4));
rowData.add(rs.getString(5));
}
model.addRow(rowData);
}
window.display(model);
//window.display(names, phones, addresses);
} catch (SQLException ex) {
ex.printStackTrace();
}
}
我將開始與Apache POI,如http://stackoverflow.com/questions/10266844/apache-poi-word-tutorial – rkosegi
我不相信Java可以做到這一點對自己。你將需要尋找一個API來使用。 – Tricky12
感謝Tricky12,你能推薦任何API嗎? – Meli