WritableSheet ws = workbook.createSheet(sheetName, index); // 创建可写入的Excel工作表
int cols = contents.length / rows; // 根据行数得出列数,在数据库里比较容易得到行数
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
Label label = new Label(col, row,contents[col + row * cols]);
ws.addCell(label); // 添加Label对象,单元格内容
}
}
workbook.write(); // 写入excel
workbook.close(); // 关闭对象,释放资源
} catch (FileNotFoundException e) {