Apache POI折线图颜色 [英] Apache POI Line Chart colors
问题描述
我正在创建带有一些统计信息(包括折线图)的Excel文件.我已经成功创建了图表并用数据填充了它们.但是我对图表系列的默认颜色不满意.
I am creating an Excel file with some statistics, also including line charts. I had succeed in creating charts and filling them with data. But I am not satisfied with default colors of the charts' series.
那么如何更改图表系列的颜色?我找不到有关它的任何文档,所以请帮忙.我还听说,该问题可能与工作簿的默认颜色有关,所以也许您可以指导我如何更改它们?
So how I can change the color of a chart serie? I can't find any documentation about it, so please help. I also heard, that problem could be connected with workbook's default colors, so maybe you can guide me how to change them?
我正在使用Apache POI 3.10.
I'm using Apache POI 3.10.
推荐答案
它对我有用. Groovy,PieChart,随机颜色.
It works for me. Groovy, PieChart, random colors.
def ctChart = chart.getCTChart()
def ctPieChart = ctChart.getPlotArea().addNewPieChart()
def ctPieSer = ctPieChart.addNewSer()
byte[] b = new byte[3];
(0 .. rows).each {
random.nextBytes(b)
def x = ctPieSer.addNewDPt()
x.addNewIdx().setVal(it)
x.addNewBubble3D().setVal(false)
x.addNewSpPr().addNewSolidFill().addNewSrgbClr().setVal(b)
}
这篇关于Apache POI折线图颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!