=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-08-22 16:03:12 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-08-22 16:10:18 +0000 @@ -37,6 +37,7 @@ import org.hisp.dhis.api.utils.ContextUtils; import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy; import org.hisp.dhis.common.Grid; +import org.hisp.dhis.system.grid.GridUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -84,6 +85,29 @@ model.addAttribute( "viewClass", "detailed" ); return "grid"; } + + @RequestMapping( value = RESOURCE_PATH + "/{program}.xls", method = RequestMethod.GET ) + public void getXls( + @PathVariable String program, + @RequestParam(required=false) String stage, + @RequestParam String startDate, + @RequestParam String endDate, + @RequestParam(required=false) String ou, + @RequestParam Set item, + @RequestParam(required=false) Set asc, + @RequestParam(required=false) Set desc, + @RequestParam(required=false) Integer page, + @RequestParam(required=false) Integer pageSize, + Model model, + HttpServletResponse response ) throws Exception + { + EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, ou, item, asc, desc, page, pageSize ); + + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true ); + Grid grid = analyticsService.getEvents( params ); + GridUtils.toXls( grid, response.getOutputStream() ); + } + // ------------------------------------------------------------------------- // Exception handling // -------------------------------------------------------------------------