文件名称:java excle生成统计图
文件大小:11KB
文件格式:PNG
更新时间:2023-08-08 11:50:45
java
Workbook wb = new XSSFWorkbook();
Sheet sheet1 = wb.createSheet("统计图");
/**
*往sheet1添加数据
*/
Drawing drawing = sheet1.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 9, 10, 19);
//
Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.TOP_RIGHT);
LineChartData data = chart.getChartDataFactory().createLineChartData();
// Use a category axis for the bottom axis.
ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
/**
*生成统计图的重要部分,从表格的那个地方开始到那个地方结束
*/
ChartDataSource