t5 and poi 用 excel 进行数据的导入导出
|
sidang1hao
2008-01-29
Anyidea?,请共享下。
1.1 java code public void onActionFromA(){
int i = 0;
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("sheet1");
try { // 此处根据您具体情况定
ResultSet rs = getJdbcManager().executeQuery("select login,last_name from user_table");
while (rs.next()) {
HSSFRow row = sheet.createRow(i);
for(short j=1;j<3;j++){
HSSFCell cell = row.createCell((short)(j-1));
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(rs.getString(j));
}
}
} catch (SQLException e){
e.printStackTrace();
}
/*此处可以直接 inject response */
1.2 tml code <t:actionLink t:id="a">aaaaaaaaa</t:actionLink>
1.3 maven dependency. <!-- poi for xls -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-contrib</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.0.2</version>
</dependency>
..\.m2\repository\org\apache\poi\poi\3.0.2\poi-3.0.2-beta2-20080112.jar 另外两包
可以运行,tapestry 5.0.6
2 ,inport data ,any idea?
|

