Excel中的颜色PieChart导出

我需要在Excel中导出一个PieChart。 出口工作到目前为止,但图表的一些颜色是相同的。 无法弄清楚问题。

代码如下:

Color[] c = this.createRainbow(100); int n = chart.getDataPointCount(0); //number of Pies ArrayList<Integer> compare = new ArrayList<Integer>(); for (int j = 0; j < n && !ValueWatcherServer.canceled_id.contains(connectionid); j++) { int rePos = (int)(((double)j / (double)n * (double)c.length)); ChartFormat format = chart.getDataPointFormat(0, j); format.setSolid(); if(!compare.contains(rePos)){ compare.add(rePos); format.setForeColor(c[rePos].getRGB()); } else{ format.setForeColor(3); } chart.setDataPointFormat(0, j, format); } 

结果是这样的: 饼形图