本篇內(nèi)容介紹了“Java怎么在PPT中創(chuàng)建SmartArt圖形”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

工具:Free Spire.Presentation for Java(免費(fèi)版)
Jar獲取及導(dǎo)入:官網(wǎng)下載jar包,并解壓將lib文件夾下的jar文件導(dǎo)入Java程序;或者通過maven倉庫下載導(dǎo)入。
這里創(chuàng)建SmartArt形狀時(shí),可在默認(rèn)創(chuàng)建的形狀中添加內(nèi)容,也可以自定義圖形節(jié)點(diǎn)來添加內(nèi)容。
import com.spire.presentation.*;
import com.spire.presentation.diagrams.*;
public class SmartArt {
public static void main(String[] args) throws Exception{
//創(chuàng)建PPT文檔,獲取一張幻燈片(創(chuàng)建的空白PPT文檔,默認(rèn)包含一張幻燈片)
Presentation ppt = new Presentation();
ISlide slide = ppt.getSlides().get(0);
//創(chuàng)建SmartArt圖形1
ISmartArt smartArt1 = slide.getShapes().appendSmartArt(50,50,200,200, SmartArtLayoutType.BASIC_CYCLE);//在幻燈片指定位置添加指定大小和布局類型的SmartArt圖形
smartArt1.setColorStyle(SmartArtColorType.COLORFUL_ACCENT_COLORS_4_TO_5);//設(shè)置SmartArt圖形顏色類型
smartArt1.setStyle(SmartArtStyleType.INTENCE_EFFECT);//設(shè)置SmartArt圖形樣式
ISmartArtNode smartArtNode1 = smartArt1.getNodes().get(0);
smartArtNode1.getTextFrame().setText("設(shè)計(jì)");//獲取默認(rèn)節(jié)點(diǎn),添加內(nèi)容
smartArt1.getNodes().get(1).getTextFrame().setText("模仿");
smartArt1.getNodes().get(2).getTextFrame().setText("學(xué)習(xí)");
smartArt1.getNodes().get(3).getTextFrame().setText("實(shí)踐");
smartArt1.getNodes().get(4).getTextFrame().setText("創(chuàng)新");
//創(chuàng)建SmartArt圖形2,自定義節(jié)點(diǎn)內(nèi)容
ISmartArt smartArt2 = slide.getShapes().appendSmartArt(400,200,200,200,SmartArtLayoutType.BASIC_RADIAL);
smartArt2.setColorStyle(SmartArtColorType.DARK_2_OUTLINE);
smartArt2.setStyle(SmartArtStyleType.MODERATE_EFFECT);
//刪除默認(rèn)的節(jié)點(diǎn)(SmartArt中的圖形)
for (Object a : smartArt2.getNodes()) {
smartArt2.getNodes().removeNode((ISmartArtNode) a);
}
//添加一個(gè)母節(jié)點(diǎn)
ISmartArtNode node2 = smartArt2.getNodes().addNode();
//在母節(jié)點(diǎn)下添加三個(gè)子節(jié)點(diǎn)
ISmartArtNode node2_1 = node2.getChildNodes().addNode();
ISmartArtNode node2_2 = node2.getChildNodes().addNode();
ISmartArtNode node2_3 = node2.getChildNodes().addNode();
//在節(jié)點(diǎn)上設(shè)置文字及文字大小
node2.getTextFrame().setText("設(shè)備");
node2.getTextFrame().getTextRange().setFontHeight(14f);
node2_1.getTextFrame().setText("機(jī)械");
node2_1.getTextFrame().getTextRange().setFontHeight(12f);
node2_2.getTextFrame().setText("電氣");
node2_2.getTextFrame().getTextRange().setFontHeight(12f);
node2_3.getTextFrame().setText("自動(dòng)化");
node2_3.getTextFrame().getTextRange().setFontHeight(12f);
// 保存文檔
ppt.saveToFile("AddSmartArt.pptx",FileFormat.PPTX_2013);
ppt.dispose();
}
}創(chuàng)建結(jié)果:

“Java怎么在PPT中創(chuàng)建SmartArt圖形”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
分享名稱:Java怎么在PPT中創(chuàng)建SmartArt圖形-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://www.chinadenli.net/article2/doseic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、企業(yè)建站、云服務(wù)器、域名注冊(cè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容