看起来你是想用gcexcel的template+chart,我做了一个excel,大概能实现你说的需求。
代码:
- @Test
- public final void testWaterfall() {
- // write test code
- List dataSource = getDataSource();
- Workbook workbook = new Workbook();
- workbook.open(("waterfall.xlsx"));
- workbook.addDataSource("ds", new JsonDataSource(JSON.toJSONString(dataSource)));
- workbook.processTemplate();
- workbook.save(("res.sjs"));
- workbook.save(("res.xlsx"));
- }
- private static List getDataSource() {
- List dataSource = new ArrayList<Map>();
- Random random = new Random();
- for (int i = 0; i < 12; i++) {
- Map rowData = new HashMap<String, String>();
- rowData.put("month", i+1);
- rowData.put("account", random.nextDouble());
- dataSource.add(rowData);
- }
- return dataSource;
- }
复制代码
|
|