我想利用jxl导出list到excel,网上的例子list都有实体类,但是我这个list是查几个表以后得到的。。
我想问下 这个应该怎么导呢。。
我想利用jxl导出list到excel,网上的例子list都有实体类,但是我这个list是查几个表以后得到的。。
我想问下 这个应该怎么导呢。。
[code="java"] List> list;//
CellFormat format;// 自己定义
WritableSheet ws;// 电子表格
int rowIndex = 0;
int columnIndex = 0;
for (Map row : list) {
// row写入到excel;
columnIndex = 0;
Set>cellSet=row.entrySet();
for (Entry data : cellSet) {
Label label = new Label(columnIndex, rowIndex, data.getValue(), new WritableCellFormat(format));
try {
ws.addCell(label);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
columnIndex++;
}
rowIndex++;
}[/code]