開心一笑
一大哥去醫(yī)院看病。
醫(yī)生問:你得了什么???
大哥說: 我得了間接性失憶癥。
醫(yī)生問:具體什么癥狀?
大哥說:我一看到漂亮的姑娘就忘記自己已結(jié)婚了。
醫(yī)生說:滾滾滾,這病我自己都沒治好!
提出問題
POI如何生成PPT的文本框及各個樣式????
解決問題
直接來例子,比較簡單,但慢慢來,一步一步的......
package com.hwy.test;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.xslf.XSLFSlideShow;
import org.apache.poi.xslf.usermodel.*;
import java.awt.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* PPT簡單導出
* Created by Ay on 2016/6/14.
*/
public class MyFirstPPTTest {
public static void main(String[] args) throws Exception{
String filePath = "D://MyPPT.pptx";
/** 加載PPT **/
XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(filePath));
/** 創(chuàng)建一個slide,理解為PPT里的每一頁 **/
XSLFSlide xslfSlide = ppt.createSlide();
/** 創(chuàng)建一個文本框 **/
XSLFTextBox xslfTextBox = xslfSlide.createTextBox();
XSLFTextBox xslfTextBox2 = xslfSlide.createTextBox();
XSLFTextBox xslfTextBox3 = xslfSlide.createTextBox();
/** 生成一個新的文本段落 **/
XSLFTextParagraph paragraph = xslfTextBox.addNewTextParagraph();
XSLFTextParagraph paragraph2 = xslfTextBox.addNewTextParagraph();
XSLFTextParagraph paragraph3 = xslfTextBox.addNewTextParagraph();
/** 添加新的文本 **/
XSLFTextRun xslfTextRun = paragraph.addNewTextRun();
XSLFTextRun xslfTextRun2 = paragraph2.addNewTextRun();
XSLFTextRun xslfTextRun3 = paragraph3.addNewTextRun();
/** 設置內(nèi)容 **/
xslfTextRun.setText("標題一");
xslfTextRun2.setText("標題二");
xslfTextRun3.setText("標題三");
/** 設置加粗 **/
xslfTextRun.setBold(true);
xslfTextRun2.setBold(true);
xslfTextRun3.setBold(true);
/** 設置顏色 **/
xslfTextRun.setFontColor(new Color(32, 33, 101));
xslfTextRun2.setFontColor(new Color(32, 33, 101));
xslfTextRun3.setFontColor(new Color(32, 33, 101));
/** 設置字體大小 **/
xslfTextRun.setFontSize(24);
xslfTextRun2.setFontSize(24);
xslfTextRun3.setFontSize(24);
/** 設置字體 **/
xslfTextRun.setFontFamily("仿宋_GB2312");
xslfTextRun2.setFontFamily("仿宋_GB2312");
xslfTextRun3.setFontFamily("仿宋_GB2312");
/** 設置斜體 和 下劃線 **/
//xslfTextRun.setItalic(true);
xslfTextRun.setUnderline(true);
xslfTextRun2.setUnderline(true);
xslfTextRun3.setUnderline(true);
/** 4個參數(shù)分別為 x , y , width , height **/
xslfTextBox.setAnchor(new Rectangle(20, 30, 100, 100));
xslfTextBox2.setAnchor(new Rectangle(20, 60, 100, 100));
xslfTextBox3.setAnchor(new Rectangle(20, 90, 100, 100));
/** 輸出文件 **/
ppt.write(new FileOutputStream(filePath));
}
}

插畫
讀書感悟
日本電影《只是愛著你》
- 她習慣于說謊,可是這樣的謊言卻再也聽不到了。
- 我只是想讓我喜歡的人所喜歡的人喜歡我而已。
- 任何時候,離別都比預期來得早,便如此,大家還是笑著說:“再見,總有一天會再見;再見,我們會在別處相見!”所以我雖然離你很遠很遠,但還是想說:再見,總有一天我們會在別處相見!