使用 Apache POI 创建 Excel 图表 [英] Create excel chart using Apache POI
问题描述
我需要从我的 Java 代码创建 Excel 表格,其中包含使用 Apache POI 库的条形图、折线图等图表.是否可以?我找不到任何有用的代码示例.
I need to create excel sheet from my Java code which contains charts like Bar chart, Line Chart etc using the Apache POI library. Is it possible? I am not able to find any useful code example for the same.
除了用于 Java 的 POI 库之外,还有其他选择吗?
Is there any other alternative for this apart from POI library for Java?
推荐答案
您只能使用 Excel 模板来保存带有 POI 的图表.这意味着您创建一个带有图表的 Excel 模板文件并将图表的数据源链接到一个定义的名称,然后您可以从 POI 加载模板文件并使用代码更改定义的名称.当前 POI 不支持从头开始创建图表.
You can only use Excel template to preserve chart with POI. It mean you create an Excel template file with chart in it and link the chart's datasource to one definedName,then you can load the template file from POI and using code to change the definedName. Current POI does not support to create Chart from scratch.
这篇关于使用 Apache POI 创建 Excel 图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!