问题如题,要导出excel,首先action部分配置如下:
<action name="deviceListXLS"
class="com.gloryscience.syntheticAnalysisCopy.action.struts.DeviceCountAction" method="getDeviceList">
<result name="success" type="jasper">
<param name="location">/jasperreports/neDeviceCountRptJasper/nelist.jasper</param>
<param name="dataSource">deviceAllReportList</param>
<param name="format">XLS</param>
<param name="contentDisposition">attachment</param>
<param name="documentName">deviceAllReportList</param>
<param name="reportParameters">parameters</param>
</result>
<interceptor-ref name="modelParamsStack" />
</action>
传参部分的java如下:
//设置子报表路径
parameters = new HashMap<String, String>();
parameters.put("subRptDir", request.getRealPath("/jasperreports/neDeviceCountRptJasper/")+"\\");
getRequest().setAttribute("parameters", parameters);
//增加数据源
getRequest().setAttribute("deviceAllReportList", deviceAllReportList);
deviceAllReportList的定义如下:
private List<DeviceAllReport> deviceAllReportList;
DeviceAllReport.java:
import java.util.List;
public class DeviceAllReport {
/**
* 市公司名称
*/
private String parentConpanyName;
/**
* 区域网元类型列表
*/
private List<DeviceReport> reportList;
public String getParentConpanyName() {
return parentConpanyName;
}
public void setParentConpanyName(String parentConpanyName) {
this.parentConpanyName = parentConpanyName;
}
public List<DeviceReport> getReportList() {
return reportList;
}
public void setReportList(List<DeviceReport> reportList) {
this.reportList = reportList;
}
}