List of usage examples for org.apache.poi.xwpf.usermodel XWPFDocument createParagraph
public XWPFParagraph createParagraph()
From source file:pqm.client.DocGenerator.java
public static void gerar_influencias(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("INFLUENCIAS DOMINANTES:"); paragraph = document.createParagraph(); run = paragraph.createRun();//from w w w .ja v a 2 s .com run.setText("Relacoes Ascendentes: "); paragraph = document.createParagraph(); run = paragraph.createRun(); for (int i = 0; i < pqm.influenciasDominantes.relacoesAscendentes.size(); i++) { run.setText(pqm.influenciasDominantes.relacoesAscendentes.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } run.setText("Relacoes Equivalentes:"); for (int i = 0; i < pqm.influenciasDominantes.relacoesEquivalentes.size(); i++) { run.setText(pqm.influenciasDominantes.relacoesEquivalentes.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } run.setText("Relacoes Externas"); for (int i = 0; i < pqm.influenciasDominantes.relacoesExternas.size(); i++) { run.setText(pqm.influenciasDominantes.relacoesExternas.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } run.setText("Controlo Funcional: "); for (int i = 0; i < pqm.influenciasDominantes.controloFuncional.size(); i++) { run.setText(pqm.influenciasDominantes.controloFuncional.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } }
From source file:pqm.client.DocGenerator.java
public static void gerar_fcs(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("FACTORES CRITICOS DE SUCESSO:"); paragraph = document.createParagraph(); run = paragraph.createRun();// w ww. j a v a 2 s .c o m for (int i = 0; i < pqm.fcs.size(); i++) { run.setText(pqm.fcs.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } }
From source file:pqm.client.DocGenerator.java
public static void gerar_pn(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("PROCESSOS DE NEGOCIO:"); paragraph = document.createParagraph(); run = paragraph.createRun();/*ww w. j av a 2 s . c om*/ for (int i = 0; i < pqm.processosNegocio.processos.size(); i++) { run.setText( pqm.processosNegocio.processos.get(i).id + " - " + pqm.processosNegocio.processos.get(i).texto); paragraph = document.createParagraph(); run = paragraph.createRun(); } }
From source file:ro.dabuno.office.integration.SimpleDocument.java
License:Apache License
public static void main(String[] args) throws Exception { XWPFDocument doc = new XWPFDocument(); XWPFParagraph p0 = doc.createParagraph(); XWPFRun r0 = p0.createRun();/*from w w w .j a v a2 s . c o m*/ r0.setBold(false); r0.setText("Domnule"); XWPFRun r00 = p0.createRun(); r00.setBold(true); r00.setText(" Ionescu Ion"); XWPFParagraph p1 = doc.createParagraph(); p1.setAlignment(ParagraphAlignment.CENTER); p1.setBorderBottom(Borders.DOUBLE); p1.setBorderTop(Borders.DOUBLE); p1.setBorderRight(Borders.DOUBLE); p1.setBorderLeft(Borders.DOUBLE); p1.setBorderBetween(Borders.SINGLE); p1.setVerticalAlignment(TextAlignment.TOP); XWPFRun r1 = p1.createRun(); r1.setBold(true); r1.setText("The quick brown fox"); r1.setBold(true); r1.setFontFamily("Courier"); r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH); r1.setTextPosition(100); XWPFParagraph p2 = doc.createParagraph(); p2.setAlignment(ParagraphAlignment.RIGHT); //BORDERS p2.setBorderBottom(Borders.DOUBLE); p2.setBorderTop(Borders.DOUBLE); p2.setBorderRight(Borders.DOUBLE); p2.setBorderLeft(Borders.DOUBLE); p2.setBorderBetween(Borders.SINGLE); XWPFRun r2 = p2.createRun(); r2.setText("jumped over the lazy dog"); r2.setStrike(true); r2.setFontSize(20); XWPFRun r3 = p2.createRun(); r3.setText("and went away"); r3.setStrike(true); r3.setFontSize(20); r3.setSubscript(VerticalAlign.SUPERSCRIPT); XWPFParagraph p3 = doc.createParagraph(); p3.setWordWrap(true); p3.setPageBreak(true); //p3.setAlignment(ParagraphAlignment.DISTRIBUTE); p3.setAlignment(ParagraphAlignment.BOTH); p3.setSpacingLineRule(LineSpacingRule.EXACT); p3.setIndentationFirstLine(600); XWPFRun r4 = p3.createRun(); r4.setTextPosition(20); r4.setText("To be, or not to be: that is the question: " + "Whether 'tis nobler in the mind to suffer " + "The slings and arrows of outrageous fortune, " + "Or to take arms against a sea of troubles, " + "And by opposing end them? To die: to sleep; "); r4.addBreak(BreakType.PAGE); r4.setText("No more; and by a sleep to say we end " + "The heart-ache and the thousand natural shocks " + "That flesh is heir to, 'tis a consummation " + "Devoutly to be wish'd. To die, to sleep; " + "To sleep: perchance to dream: ay, there's the rub; " + "......."); r4.setItalic(true); //This would imply that this break shall be treated as a simple line break, and break the line after that word: XWPFRun r5 = p3.createRun(); r5.setTextPosition(-10); r5.setText("For in that sleep of death what dreams may come"); r5.addCarriageReturn(); r5.setText("When we have shuffled off this mortal coil," + "Must give us pause: there's the respect" + "That makes calamity of so long life;"); r5.addBreak(); r5.setText("For who would bear the whips and scorns of time," + "The oppressor's wrong, the proud man's contumely,"); r5.addBreak(BreakClear.ALL); r5.setText("The pangs of despised love, the law's delay," + "The insolence of office and the spurns" + "......."); FileOutputStream out = new FileOutputStream("simple.docx"); doc.write(out); out.close(); }
From source file:ro.dabuno.office.integration.Xlsx2Word.java
public static void main(String[] args) throws Exception { log.info("starting app"); // Workbook wb = new XSSFWorkbook(new FileInputStream(args[0])); Workbook wb = new XSSFWorkbook(new FileInputStream("office-files/Input.xlsx")); DataFormatter formatter = new DataFormatter(); for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i);/*from w w w. j av a 2 s . c o m*/ System.out.println(wb.getSheetName(i)); int j = 4; for (Row row : sheet) { System.out.println("rownum: " + row.getRowNum()); for (Cell cell : row) { CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex()); System.out.print(cellRef.formatAsString()); System.out.print(" - "); // get the text that appears in the cell by getting the cell value and applying any data formats (Date, 0.00, 1.23e9, $1.23, etc) String text = formatter.formatCellValue(cell); System.out.println(text); System.out.println("------------"); // Alternatively, get the value and format it yourself switch (cell.getCellTypeEnum()) { case STRING: System.out.println(cell.getRichStringCellValue().getString()); break; case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { System.out.println(cell.getDateCellValue()); } else { System.out.print(cellRef.formatAsString()); System.out.print(" - "); System.out.println((long) cell.getNumericCellValue()); } break; case BOOLEAN: System.out.println(cell.getBooleanCellValue()); break; case FORMULA: System.out.println(cell.getCellFormula()); break; case BLANK: System.out.println(); break; default: System.out.println(); } } j--; if (j == 0) { break; } } } XWPFDocument doc = new XWPFDocument(); XWPFParagraph p0 = doc.createParagraph(); XWPFRun r0 = p0.createRun(); r0.setBold(false); r0.setText("Domnule"); XWPFRun r00 = p0.createRun(); r00.setBold(true); r00.setText(" Ionescu Ion"); FileOutputStream out = new FileOutputStream("out/xlsx2word.docx"); doc.write(out); out.close(); }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
public static OntologyReport generate(OntModel model) { XWPFDocument wordDocument = new XWPFDocument(); List<OntClass> classes = new ArrayList<OntClass>(model.listNamedClasses().toList()); Collections.sort(classes, new OntClassByCodeComparator()); Set<String> allClassesIds = new LinkedHashSet<String>(); for (OntClass ontClass : classes) { allClassesIds.add(ontClass.getLocalName()); addURI(wordDocument, ontClass);// ww w. j ava 2 s. co m addSuperclasses(wordDocument, ontClass); addSubclasses(wordDocument, ontClass); addComment(wordDocument, ontClass); wordDocument.createParagraph().setSpacingAfter(10); addProperties(wordDocument, ontClass); } return new OntologyReport(wordDocument, classesWithEmptyComments, allClassesIds); }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
private static void addProperties(XWPFDocument wordDocument, OntClass ontClass) { Set<OntClass> equivalentClasses = ontClass.listEquivalentClasses().toSet(); if (equivalentClasses.isEmpty()) return;//from ww w. ja v a 2s . c om XWPFParagraph paragraph = wordDocument.createParagraph(); paragraph.setStyle("style0"); XWPFRun run = paragraph.createRun(); run.setText("?: "); for (OntClass equivalentClass : equivalentClasses) { if (!equivalentClass.isRestriction()) continue; AllValuesFromRestriction restriction = equivalentClass.asRestriction().asAllValuesFromRestriction(); XWPFParagraph p = wordDocument.createParagraph(); p.setIndentationLeft(1440); XWPFRun r = p.createRun(); OntProperty onProperty = restriction.getOnProperty(); OntClass toClass = restriction.getAllValuesFrom().as(OntClass.class); r.setText(format("%s: %s", formatPropertyURI(onProperty), formatURI(toClass))); r.setItalic(true); } wordDocument.createParagraph().setIndentationLeft(1440); }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
private static void addComment(XWPFDocument wordDocument, OntClass ontClass) { String comment = null;/*from w ww . jav a2 s . com*/ if (ontClass.getComment(RU_LOCALE) != null) { comment = ontClass.getComment(RU_LOCALE); } else if (ontClass.getComment(EN_LOCALE) != null) { comment = ontClass.getComment(EN_LOCALE); } else { comment = ontClass.getComment(null); } if (comment == null || comment.isEmpty()) { classesWithEmptyComments.add(formatURI(ontClass)); return; } XWPFParagraph paragraph = wordDocument.createParagraph(); paragraph.setStyle("style0"); XWPFRun run = paragraph.createRun(); run.setText(format("?: \n%s", comment != null ? comment.replace("http://", ". http://").replace("www.", ". www.") : "")); }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
private static void addNeighbourClasses(XWPFDocument wordDocument, Set<OntClass> classes, String header) { if (classes.isEmpty()) return;//from www . j a v a 2 s.c o m XWPFParagraph paragraph = wordDocument.createParagraph(); paragraph.setStyle("style0"); XWPFRun run = paragraph.createRun(); run.setText(header); StringBuilder sb = new StringBuilder(); List<OntClass> classList = new ArrayList<OntClass>(classes); Collections.sort(classList, new OntClassByLabelComparatorAsc()); Iterator<OntClass> it = classList.iterator(); while (it.hasNext()) { OntClass clazz = it.next(); sb.append(formatURI(clazz)); if (it.hasNext()) { sb.append("; "); } } XWPFParagraph p = wordDocument.createParagraph(); p.setIndentationLeft(1440); XWPFRun r = p.createRun(); r.setText(sb.toString()); r.setItalic(true); wordDocument.createParagraph().setIndentationLeft(1440); }
From source file:ru.ksu.niimm.cll.mocassin.rdf.ontology.util.OntologyReportGenerator.java
License:Open Source License
private static void addURI(XWPFDocument wordDocument, OntClass ontClass) { XWPFParagraph paragraph = wordDocument.createParagraph(); paragraph.setSpacingBefore(10);//from w ww .java 2 s.co m paragraph.setStyle("Heading 5"); XWPFRun run = paragraph.createRun(); run.setText(formatURI(ontClass)); }