TenderPriceExcelController extends ExcelChartOCDSController { @ApiOperation(value = "Exports *Bid selection* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/bidSelectionExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public void bidSelectionExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter, final HttpServletResponse response) throws IOException { final String chartTitle = translationService.getValue(filter.getLanguage(), "charts:bidSelectionMethod:title"); final List<DBObject> tenderPriceByBidSelection = tenderPriceByTypeYearController.tenderPriceByBidSelectionMethod(filter); final List<?> categories = excelChartHelper.getCategoriesFromDBObject( TenderPriceByTypeYearController.Keys.PROCUREMENT_METHOD_DETAILS, tenderPriceByBidSelection); final List<List<? extends Number>> values = new ArrayList<>(); final List<Number> totalTenderAmount = excelChartHelper.getValuesFromDBObject(tenderPriceByBidSelection, categories, TenderPriceByTypeYearController.Keys.PROCUREMENT_METHOD_DETAILS, TenderPriceByTypeYearController.Keys.TOTAL_TENDER_AMOUNT); for (int i = 0; i < totalTenderAmount.size(); i++) { if (totalTenderAmount.get(i) != null) { totalTenderAmount.set(i, totalTenderAmount.get(i).doubleValue() / 1000000000); } } values.add(totalTenderAmount); final List<String> seriesTitle = Arrays.asList( translationService.getValue(filter.getLanguage(), "charts:cancelledFunding:yAxisTitle")); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=" + chartTitle + ".xlsx"); response.getOutputStream().write( excelChartGenerator.getExcelChart( ChartType.barcol, chartTitle, seriesTitle, categories, values)); }  @ApiOperation(value = "Exports *Bid selection* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/bidSelectionExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void bidSelectionExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                       final HttpServletResponse response); @ApiOperation(value = "Exports *Procurement method* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/procurementMethodExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void procurementMethodExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                            final HttpServletResponse response);  }
@Test public void bidSelectionExcelChart() throws Exception { LangYearFilterPagingRequest filter = getLangYearFilterMockRequest(); tenderPriceExcelController.bidSelectionExcelChart( filter, mockHttpServletResponse); final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray(); final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput)); Assert.assertNotNull(workbook); final Sheet sheet = workbook.getSheet(ChartType.barcol.toString()); Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet); final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch(); final List<XSSFChart> charts = drawing.getCharts(); Assert.assertEquals("number of charts", 1, charts.size()); final XSSFChart chart = charts.get(0); Assert.assertEquals("chart title",translationService.getValue(filter.getLanguage(), "charts:bidSelectionMethod:title") , chart.getTitle().getString()); final List<? extends XSSFChartAxis> axis = chart.getAxis(); Assert.assertEquals("number of axis", 2, axis.size()); final CTChart ctChart = chart.getCTChart(); Assert.assertEquals("Check if we have 1 bar chart", 1, ctChart.getPlotArea().getBarChartArray().length); }