Search in sources :

Example 51 with XSSFChart

use of org.apache.poi.xssf.usermodel.XSSFChart in project oc-explorer by devgateway.

the class TotalCancelledTendersExcelControllerTest method cancelledFundingExcelChart.

@Test
public void cancelledFundingExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    totalCancelledTendersExcelController.cancelledFundingExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.area.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:cancelledAmounts: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 area chart", 1, ctChart.getPlotArea().getAreaChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Aggregations

XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)51 Workbook (org.apache.poi.ss.usermodel.Workbook)31 Test (org.junit.Test)31 CTChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTChart)30 Sheet (org.apache.poi.ss.usermodel.Sheet)29 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)29 XSSFDrawing (org.apache.poi.xssf.usermodel.XSSFDrawing)28 ByteArrayInputStream (java.io.ByteArrayInputStream)25 LangYearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest)23 CTPlotArea (org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)18 ChartAxis (org.apache.poi.ss.usermodel.charts.ChartAxis)17 CustomChartSeries (org.devgateway.toolkit.web.excelcharts.CustomChartSeries)14 CTValAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx)10 CTLineChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart)5 CTCatAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx)4 AddTrace (com.google.firebase.perf.metrics.AddTrace)3 SpreadsheetUtils.getCellRangeAddress (com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getCellRangeAddress)3 SpreadsheetUtils.getMetricForChart (com.supercilex.robotscouter.data.client.spreadsheet.SpreadsheetUtils.getMetricForChart)3 PreferencesUtilsKt.setShouldShowExportHint (com.supercilex.robotscouter.util.PreferencesUtilsKt.setShouldShowExportHint)3 PreferencesUtilsKt.shouldShowExportHint (com.supercilex.robotscouter.util.PreferencesUtilsKt.shouldShowExportHint)3