public void createFixationSheet(List list, OutputStream os)
throws IOException {
HSSFSheet sheet = wb.createSheet("new sheet");
wb.setSheetName(0, "话费详单");
HSSFRow row = sheet.createRow((short) 0);
sheet.createFreezePane(0, 1);
cteateCell(wb, row, (short) 0, "用户姓名");
cteateCell(wb, row, (short) 1, "早餐次数");
cteateCell(wb, row, (short) 2, "午餐次数");
cteateCell(wb, row, (short) 3, "晚餐次数");
cteateCell(wb, row, (short) 4, "总次数");
cteateCell(wb, row, (short) 5, "总价格"); int ii = 0;
ii = list.size();
for (int i = 0; i < list.size(); i++) {
i++;
HSSFRow row2 = sheet.createRow((short) i);
String ss = "";
if (list.get(ii) == null)
ss = "空  null";
else
ss = (String) list.get(ii);
cteateCell(wb, row2, (short) ii, ss);
}
wb.write(os);
os.flush();
os.close();
}      public class DownActionAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) { System.out.println(request.getParameter("beginningDate")); String name = "detial";// Excel文件名
OutputStream os = null;
try {
os = response.getOutputStream();
} catch (IOException e1) {
e1.printStackTrace();
}// 取得输出流
response.reset();// 清空输出流
response.setHeader("Content-disposition", "attachment; filename="
+ name + ".xls");
// 设定输出文件头,该方法有两个参数,分别表示应答头的名字和值。 response.setContentType("application/msexcel");
// 定义输出类型 ExcelBean eb = new ExcelBean(); List list = new ArrayList();
list.add("111111");
list.add("222222");
list.add("3333333");
list.add("4444444");
list.add("4444444");
list.add("4444444"); try {
eb.createFixationSheet(list, os);
} catch (IOException e) {
e.printStackTrace();
}// 调用生成excel文件bean return mapping.findForward("fail");

我想讲一个集合写到EXCEL里 为什么不行啊 用的是POI