本来我以为已经完事了,找头头过来让他看看,他说一般hibernate多表查询之后返回的List里面的内容一般都是Map类型的,我前面写的那个是List<Object>,我以为可以的。。。但是我试了一下,传一个List<Map>进去,结果输出的结果我也看不懂了,没办法,只好再写个处理List<Map>的方法:代码如下
package com.zhangbinhui.ManageBean;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
/***
* @author lsf
*/
@ManagedBean
@ViewScoped
public class MakeExcel {
/***************************************************************************
* @param fileName
* EXCEL文件名称
* @param listTitle
* EXCEL文件第一行列标题集合
* @param listContent
* EXCEL文件正文数据集合
* @return
*/
String fileName;
String[] Title;
List<Object> listContent;
public String exportExcel(ActionEvent event) {
fileName = (String)event.getComponent().getAttributes().get("filename");
String title = (String)event.getComponent().getAttributes().get("titles");
Title = title.split(",");