-1
테이블에 이미지를 추가하는 방법 (java)의 poi api에서 powerpoint poi api의 이미지를 추가하는 방법, poi latest jar poi를 통해 CTBlipFillProperties를 가져올 수 없습니다. poi- 자바 파워 포인트 POI API를 테이블 (XSLFTable) 셀에 이미지를 추가하는 방법을 3.15.jar , 우리는 당신은 아주 가까웠다테이블에 이미지를 추가하는 방법
public static void main(String[] args) throws Exception {
XMLSlideShow pptx = new XMLSlideShow();
XSLFSlide slide = pptx.createSlide();
// you need to include ooxml-schemas:1.1 for this to work!!!
// otherwise an empty table will be created
// see https://issues.apache.org/bugzilla/show_bug.cgi?id=49934
XSLFTable table = slide.createTable();
table.setAnchor(new Rectangle2D.Double(50, 50, 500, 20));
XSLFTableRow row = table.addRow();
row.addCell().setText("Cell 1");
XSLFTableCell cell = row.addCell();
cell.setText("Cell 2");
CTBlipFillProperties blipPr = cell.getXmlObject().getTcPr().addNewBlipFill();
blipPr.setDpi(72);
// http://officeopenxml.com/drwPic-ImageData.php
CTBlip blib = blipPr.addNewBlip();
blipPr.addNewSrcRect();
CTRelativeRect fillRect = blipPr.addNewStretch().addNewFillRect();
fillRect.setL(30000);
fillRect.setR(30000);
PackagePartName partName = PackagingURIHelper.createPartName("/ppt/media/100px.gif");
PackagePart part = pptx.getPackage().createPart(partName, "image/gif");
OutputStream partOs = part.getOutputStream();
FileInputStream fis = new FileInputStream("src/test/resources/100px.gif");
byte buf[] = new byte[1024];
for (int readBytes; (readBytes = fis.read(buf)) != -1; partOs.write(buf, 0, readBytes));
fis.close();
partOs.close();
PackageRelationship prs = slide.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
blib.setEmbed(prs.getId());
FileOutputStream fos = new FileOutputStream("test2.pptx");
pptx.write(fos);
fos.close();
}
스택 오버플로에 오신 것을 환영합니다! 훌륭한 답을주기 위해, 아직하지 않았다면 한눈에 알아볼 수 있습니다. [mcve]를 제공 할 수 있다면 유용 할 수도 있습니다. – Mat
POI를 통해 pptx에서 XSLFTextParagraph에 이미지를 추가하는 방법 –