Java PowerPoint에서 그래프에 데이터 레이블 추가
아래 준비
1.E-iceblue 공식 사이트에서 Free Spire. Presentation for Java 무료 버전을 다운로드합니다.
![](https://s1.md5.ltd/image/820fd5796c5d72d4850953320f675cd9.png)
![](https://s1.md5.ltd/image/34de4d8e474ef117e807215c36f9cfed.png)
원본 파일
![](https://s1.md5.ltd/image/9f1b816f7d580b1de2c1bd57a99d7297.png)
import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;
import com.spire.presentation.charts.IChart;
import com.spire.presentation.charts.entity.ChartDataLabel;
import com.spire.presentation.charts.entity.ChartSeriesDataFormat;
import com.spire.presentation.drawing.FillFormatType;
import java.awt.*;
public class AddDataLabelsToChart {
public static void main(String[] args) throws Exception {
//PowerPointをロードします。
Presentation ppt = new Presentation();
ppt.loadFromFile("Chart.pptx");
//スライドを取得します。
ISlide slide = ppt.getSlides().get(0);
//チャートを取得します。
IChart chart = (IChart)slide.getShapes().get(0);
//グラフの系列を取得します。
for (ChartSeriesDataFormat series:(Iterable)chart.getSeries()
) {
//各系列にデータラベルをつけます。
for(int i = 0; i < 4; i++){
ChartDataLabel dataLabel = series.getDataLabels().add();
//ラベルの値を表示します。
dataLabel.setLabelValueVisible(true);
//ラベルの系列を表示します。
dataLabel.setSeriesNameVisible(true);
//ラベルの枠を設定します。
dataLabel.getLine().setFillType(FillFormatType.SOLID);
dataLabel.getLine().getSolidFillColor().setColor(Color.RED);
//ラベルの塗りつぶしを設定します。
dataLabel.getFill().setFillType(FillFormatType.SOLID);
dataLabel.getFill().getSolidColor().setColor(Color.YELLOW);
}
}
//保存します。
ppt.saveToFile("DataLabels.pptx", FileFormat.PPTX_2013);
}
}
실행 결과
![](https://s1.md5.ltd/image/1fb43e1c76e595c9e9885f30b5fab68f.png)
Reference
이 문제에 관하여(Java PowerPoint에서 그래프에 데이터 레이블 추가), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/iceblue/items/24dc06fa51531e47b445텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)