List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph createRun
public XWPFRun createRun()
From source file:csv2docxconverter.DocumentGenerator.java
/** * Set header cell style// w ww . ja va2 s.co m */ private XWPFRun setHeaderCell(XWPFTableCell cell) { cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); XWPFParagraph paragraph = cell.getParagraphArray(0); paragraph.setAlignment(ParagraphAlignment.CENTER); paragraph.setSpacingBefore(8); paragraph.setSpacingAfter(8); XWPFRun run = paragraph.createRun(); run.setBold(true); return run; }
From source file:csv2docxconverter.DocumentGenerator.java
/** * Set body cell style/*from w w w. j av a 2 s . c o m*/ */ private XWPFRun setBodyCell(XWPFTableCell cell) { cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); XWPFParagraph paragraph = cell.getParagraphArray(0); paragraph.setAlignment(ParagraphAlignment.CENTER); paragraph.setSpacingBefore(4); paragraph.setSpacingAfter(4); return paragraph.createRun(); }
From source file:de.knowwe.include.export.FootnoteExporter.java
License:Open Source License
@Override public void export(Section<FootnoteType> section, DocumentBuilder manager) throws ExportException { // find id for our footnote String refNumber = section.get().getFootnoteID(section); BigInteger noteId = getFootnoteIDInternal(manager, section.getArticle(), refNumber); // create footnote for that id CTFtnEdn ctNote = CTFtnEdn.Factory.newInstance(); ctNote.setId(noteId);//from w ww. j a v a 2 s . c o m ctNote.setType(STFtnEdn.NORMAL); XWPFFootnotes footnotes = manager.getDocument().createFootnotes(); XWPFFootnote footnote = footnotes.addFootnote(ctNote); // add contents to footer XWPFParagraph footPara = footnote.addNewParagraph(CTP.Factory.newInstance()); footPara.setStyle(Style.footnote.getStyleName()); XWPFRun footRun = footPara.createRun(); footRun.setSubscript(VerticalAlign.SUPERSCRIPT); footRun.setText(String.valueOf(noteId.intValue())); footRun = footPara.createRun(); footRun.setSubscript(VerticalAlign.BASELINE); DocumentBuilder contentBuilder = new ListBuilder(manager, footPara, Style.text); contentBuilder.export(section.getChildren()); }
From source file:de.knowwe.include.export.HeaderExporter.java
License:Open Source License
public static XWPFRun createCrossReferenceRun(String refID, DocumentBuilder builder) { XWPFParagraph paragraph = builder.getParagraph(); if (refID == null) { return paragraph.createRun(); } else {/*from ww w . j av a 2 s . c om*/ HeaderExporter self = builder.getModel().getExporter(HeaderExporter.class); BigInteger id = BigInteger.valueOf(self.bookmarkIndex++); CTP ctp = paragraph.getCTP(); CTBookmark start = ctp.addNewBookmarkStart(); start.setId(id); start.setName(refID); XWPFRun run = paragraph.createRun(); CTMarkupRange end = ctp.addNewBookmarkEnd(); end.setId(id); return run; } }
From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java
License:Apache License
/** * Fgt einzele Tests aus einem Test-Case hinzu * /* www. ja va 2 s . c o m*/ * @param fInfo the file information */ private void addTestMethods(FileInfo fInfo) { for (MethodInfo mInfo : fInfo.getMethodInfos()) { addH2(mInfo.getMethodName()); // Java-Doc Test-Methode if (mInfo.getJavaDocInfo() != null && mInfo.getJavaDocInfo().getTitle() != null) { addPar("Testbeschreibung", mInfo.getJavaDocInfo().getTitle()); } // Autoren if (mInfo.getJavaDocInfo() != null && mInfo.getJavaDocInfo().getTagInfo("@author") != null && mInfo.getJavaDocInfo().getTagInfo("@author").isEmpty() == false) { List<String> authors = new ArrayList<String>(); for (Pair<String, String> author : mInfo.getJavaDocInfo().getTagInfo("@author")) { authors.add(author.getSecond()); } addPar("Autoren Tests", authors.toArray(new String[authors.size()])); } addPar("Testablauf", mInfo.getTestSteps().size() == 0 ? "Keine Daten" : ""); // Parameter in neue Zeilen hinzufgen XWPFTable testStepTable = document.createTable(); setTableStyle(testStepTable, "TabelleProfessionell"); XWPFTableRow headRow = testStepTable.getRow(0); headRow.getCell(0).setText("#"); headRow.addNewTableCell().setText("Vorgehen"); for (TestStepInfo tInfo : mInfo.getTestSteps()) { XWPFTableRow row = testStepTable.createRow(); setColor("EDEDED", row.getCell(0).getCTTc()); // graue steps setColor("EDEDED", row.getCell(1).getCTTc()); row.getCell(0).setText("#" + tInfo.getTestStep()); if (tInfo.getTbJavaDocInfo() != null) { row.getCell(1).setText(tInfo.getTbJavaDocInfo().getTitle()); } else { row.getCell(1).setText("Keine Daten"); } // Aufrufparameter if (tInfo.getParameters() != null && tInfo.getParameters().isEmpty() == false) { for (ParameterInfo pInfo : tInfo.getParameters()) { XWPFTableRow pRow = testStepTable.createRow(); XWPFParagraph p = pRow.getCell(1).getParagraphs().get(0); XWPFRun pRun = p.createRun(); pRun.setText(pInfo.getJavaDoc() + ": " + pInfo.getParamValue()); pRow.getCell(1).addParagraph(p); } } } // Falls vorhanden auch Screenshots in die Doku aufnehmen addScreenShotsIfExists(mInfo); } }
From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java
License:Apache License
/** * Fgt einen Seitemumbruch ein//from www. j a va 2 s . c om */ private void addPageBreak() { XWPFParagraph breakPar = document.createParagraph(); XWPFRun run2 = breakPar.createRun(); run2.addBreak(BreakType.PAGE); }
From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java
License:Apache License
/** * Fgt eine berschrift 1. Ebene ein/*w ww.jav a 2 s.co m*/ * * @param heading * der Titel */ private void addH1(String heading) { XWPFParagraph headPar = document.createParagraph(); headPar.setStyle("berschrift1"); XWPFRun run = headPar.createRun(); run.setText(heading); }
From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java
License:Apache License
/** * Fgt eine berschrift 2. Ebene ein/* w ww .j a v a2 s. com*/ * * @param heading * der Titel */ private void addH2(String heading) { XWPFParagraph headPar = document.createParagraph(); headPar.setStyle("berschrift2"); XWPFRun run = headPar.createRun(); run.setText(heading); }
From source file:de.micromata.tpsb.doc.renderer.MicrosoftWordRenderer.java
License:Apache License
/** * Fgt einen neuen Paragraphen ein./*from w ww . j a va 2 s . com*/ * * @param title * Titel des Abschnitts * @param content * Inhalt (mehrere Zeilen mglich) */ private void addPar(String title, String... content) { XWPFParagraph par = document.createParagraph(); XWPFRun titleRun = par.createRun(); titleRun.setBold(true); titleRun.addCarriageReturn(); titleRun.setText(title); titleRun.addCarriageReturn(); for (String line : content) { XWPFRun contentRun = par.createRun(); contentRun.setText(line); } }
From source file:demo.poi.image.SimpleImages.java
License:Apache License
static void writeImageToDoc(String[] args) throws InvalidFormatException, IOException, FileNotFoundException { XWPFDocument doc = new XWPFDocument(); XWPFParagraph p = doc.createParagraph(); XWPFRun r = p.createRun(); for (String imgFile : args) { int format; if (imgFile.endsWith(".emf")) format = XWPFDocument.PICTURE_TYPE_EMF; else if (imgFile.endsWith(".wmf")) format = XWPFDocument.PICTURE_TYPE_WMF; else if (imgFile.endsWith(".pict")) format = XWPFDocument.PICTURE_TYPE_PICT; else if (imgFile.endsWith(".jpeg") || imgFile.endsWith(".jpg")) format = XWPFDocument.PICTURE_TYPE_JPEG; else if (imgFile.endsWith(".png")) format = XWPFDocument.PICTURE_TYPE_PNG; else if (imgFile.endsWith(".dib")) format = XWPFDocument.PICTURE_TYPE_DIB; else if (imgFile.endsWith(".gif")) format = XWPFDocument.PICTURE_TYPE_GIF; else if (imgFile.endsWith(".tiff")) format = XWPFDocument.PICTURE_TYPE_TIFF; else if (imgFile.endsWith(".eps")) format = XWPFDocument.PICTURE_TYPE_EPS; else if (imgFile.endsWith(".bmp")) format = XWPFDocument.PICTURE_TYPE_BMP; else if (imgFile.endsWith(".wpg")) format = XWPFDocument.PICTURE_TYPE_WPG; else {//from ww w . j av a2 s . com System.err.println("Unsupported picture: " + imgFile + ". Expected emf|wmf|pict|jpeg|png|dib|gif|tiff|eps|bmp|wpg"); continue; } r.setText(imgFile); r.addBreak(); r.addPicture(new FileInputStream(imgFile), format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 // pixels r.addBreak(BreakType.PAGE); } FileOutputStream out = new FileOutputStream("images.docx"); doc.write(out); out.close(); // doc.close(); }