我有一个使用dynamicjasper在xls中创建报表的服务类,我想知道如何在我的flex应用程序中包含一个按钮来执行此方法。
@Service("downloadService")
@Transactional
public class DownServiceRelTemp {
private static Logger logger = Logger.getLogger("service");
@Resource(name="sessionFactory")
private SessionFactory sessionFactory;
public void downloadXLS(HttpServletResponse response) throws ColumnBuilderException,
ClassNotFoundException, JRException {
logger.debug("Downloading Excel report");
DynamicReport dr = LayouteRelTemp.buildReportLayout();
JRDataSource ds = getDataSource();
JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(), null);
JasperPrint jp = JasperFillManager.fillReport(jr, null, ds);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Exporter.exportToXLS(jp, baos);
String fileName = "MyReport.xls";
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
response.setContentType("application/vnd.ms-excel");
response.setContentLength(baos.size());
Writer.write(response, baos);
}
任何建议,对adobe flex都没有多少经验,想要一个简单的帮助。