開(kāi)心一笑
昨晚被一道神題考住了!
( )( ) ( )2 4 6 7 8
讓我填空~我按照數(shù)列組合算了一下午都不對(duì)
最后,
答案是這樣的
(門(mén)前大橋下)(游過(guò)一群鴨) (快來(lái)快來(lái)數(shù)一數(shù))
2 4 6 7 8
我tm到現(xiàn)在都不想說(shuō)話…
提出問(wèn)題
POI中PPT如何添加表格???
解決問(wèn)題

19.png
一下只是一個(gè)簡(jiǎn)單的例子,具體生成表格,一般都是封裝成方法,不過(guò)沒(méi)事慢慢來(lái),一步一步滴......
package com.hwy.test;
import org.apache.poi.xslf.usermodel.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* PPT簡(jiǎn)單導(dǎo)出
* Created by Ay on 2016/6/18.
*/
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)建一個(gè)slide,理解為PPT里的每一頁(yè) **/
XSLFSlide slide = ppt.createSlide();
/** 獲得slideMasters**/
XSLFSlideMaster[] slideMasters = ppt.getSlideMasters();
/** 創(chuàng)建表格**/
XSLFTable table = slide.createTable();
/** 設(shè)置表格 x ,y ,width,height **/
Rectangle2D rectangle2D = new Rectangle2D.Double(20,90,700,500);
/** 生成第一行 **/
XSLFTableRow firstRow = table.addRow();
/** 生成第一個(gè)單元格**/
XSLFTableCell firstCell = firstRow.addCell();
/** 設(shè)置單元格的邊框顏色 **/
firstCell.setBorderBottomColor(new Color(10,100,120));
firstCell.setBorderRightColor(new Color(10,100,120));
firstCell.setBorderLeftColor(new Color(10,100,120));
firstCell.setBorderTopColor(new Color(10,100,120));
/** 設(shè)置單元格邊框 **/
firstCell.setBorderLeft(3);
firstCell.setBorderRight(3);
firstCell.setBorderTop(3);
firstCell.setBorderBottom(3);
/** 設(shè)置文本 **/
firstCell.setText("AAA");
/** 設(shè)置單元格的邊框?qū)挾?**/
XSLFTableCell secondCell = firstRow.addCell();
secondCell.setText("BBB");
/** 設(shè)置單元格的邊框顏色 **/
secondCell.setBorderBottomColor(new Color(10,100,120));
secondCell.setBorderRightColor(new Color(10,100,120));
secondCell.setBorderLeftColor(new Color(10,100,120));
secondCell.setBorderTopColor(new Color(10,100,120));
/** 設(shè)置單元格邊框 **/
secondCell.setBorderLeft(3);
secondCell.setBorderRight(3);
secondCell.setBorderTop(3);
secondCell.setBorderBottom(3);
table.setAnchor(rectangle2D);
/** 輸出文件 **/
ppt.write(new FileOutputStream(filePath));
}
}
結(jié)果:
這里寫(xiě)圖片描述
讀書(shū)感悟
來(lái)自《羅馬假日》
- 現(xiàn)在,我必須離開(kāi)了。我走到街角,然后轉(zhuǎn)彎。答應(yīng)我,別看著我,把車(chē)開(kāi)走,離開(kāi)我,就像我離開(kāi)你。
- 羅馬不是一日建成的.