OutputStream out) throws IOException
{
wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(sheetName);
// 创建第1行,也就是输出表头
HSSFRow row = sheet.createRow(0);
HSSFCell cell;
for (int i = 0; i < columnNames.length; i++)
{
cell = row.createCell(i);
cell.setCellValue(new HSSFRichTextString(columnNames[i]));
}
// 下面是输出各行的数据
for (int i = 0; i < list.size(); i++)
{
row = sheet.createRow(i + 1);
Object o = list.get(i);
for (int j = 0; j < columnPropterties.length; j++)
{
cell = row.createCell(j);
Object obj = ReflectionUtils.invokeGetterMethod(o, columnPropterties[j]);
cell.setCellValue(obj == null ? "" : obj.toString());
}
}
wb.write(out);