List of usage examples for org.apache.poi.xwpf.usermodel XWPFRun setText
public void setText(String value)
From source file:poitest.TemplateConvert.java
License:Open Source License
public static void main(String[] args) throws Exception { ExportManager export = new ExportManager(null); ExportModel model = new ExportModel(export, ExportManager.createDefaultTemplateStream()); DefaultBuilder builder = new DefaultBuilder(model); XWPFRun run = builder.getParagraph(Style.text).createRun(); run.setText("Hallo Welt!\n"); run = builder.getNewParagraph(Style.heading1).createRun(); run.setText("Hallo berschrift\n"); run = builder.getParagraph(Style.text).createRun(); run.setText(//www . java 2 s . co m "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n"); run = builder.getNewParagraph(Style.heading2).createRun(); run.setText("Und etwas kleiner\n"); run = builder.getNewParagraph(Style.heading3).createRun(); run.setText("Und noch kleiner\n"); run = builder.getNewParagraph(Style.heading2).createRun(); run.setText("Und etwas kleiner\n"); PackageProperties properties = builder.getDocument().getPackage().getPackageProperties(); properties.setRevisionProperty("13"); properties.setCreatorProperty("Volker POI"); properties.setTitleProperty("MMP Qatar Test Document"); File folder = new File("target/result"); folder.mkdirs(); try (FileOutputStream stream = new FileOutputStream(new File(folder, "Test.docx"))) { builder.getDocument().write(stream); } System.out.println("Done."); Exec.runSimpleCommand("open Test.docx", folder); }
From source file:pqm.client.DocGenerator.java
public void work() { FileOutputStream out = null;/*www .j a v a 2s . c o m*/ try { XWPFDocument document = new XWPFDocument(); out = new FileOutputStream(new File("C:\\Users\\Tiago\\Desktop\\gsiteste.docx")); XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("PQM"); paragraph = document.createParagraph(); run = paragraph.createRun(); run.setText("2015-2016"); document.createParagraph(); gerar_introducao(document); document.createParagraph(); gerar_missao(document); document.createParagraph(); //gerar_influencias(document); document.createParagraph(); gerar_fcs(document); document.createParagraph(); gerar_pn(document); document.createParagraph(); tabela_fcs_pn(document); /*tabela fcs vs pcn*/ document.createParagraph(); gerar_matriz1(document); document.createParagraph(); tabela_importancia(document); /*tabela analise */ document.createParagraph(); gerar_matriz2(document); document.createParagraph(); gerar_conclusao(document); document.write(out); out.close(); System.out.println("createdocument.docx written successully"); } catch (FileNotFoundException ex) { Logger.getLogger(DocGenerator.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(DocGenerator.class.getName()).log(Level.SEVERE, null, ex); } finally { try { out.close(); } catch (IOException ex) { Logger.getLogger(DocGenerator.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:pqm.client.DocGenerator.java
public static void gerar_introducao(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("INTRODUCAO:"); paragraph = document.createParagraph(); run = paragraph.createRun();/*from www . j a va 2 s.co m*/ run.setText(pqm.introducao.texto); }
From source file:pqm.client.DocGenerator.java
public static void tabela_fcs_pn(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("MATRIZES DA METODOLOGIA PQM:"); XWPFTable table = document.createTable(); XWPFTableRow tableRowOne = table.getRow(0); tableRowOne.getCell(0).setText(""); teste t1 = new teste(); pqm = t1.escreve();//w ww. ja va2 s .co m /* ler fcs e colocar na tabela*/ int num_fcs = pqm.fcs.size(); for (int i = 0; i < num_fcs; i++) { tableRowOne.addNewTableCell().setText(pqm.fcs.get(i).texto); } /*criar analise */ for (int i = 0; i < 3; i++) { tableRowOne.addNewTableCell(); } tableRowOne.getCell(num_fcs + 1).setText("Tot. Imp"); tableRowOne.getCell(num_fcs + 2).setText("Qual. Proc."); tableRowOne.getCell(num_fcs + 3).setText("Proc. Gast"); /*processos*/ for (int j = 0; j < pqm.processosNegocio.processos.size(); j++) { int contador = 0; XWPFTableRow tableRow = table.createRow(); tableRow.getCell(0).setText("" + pqm.processosNegocio.processos.get(j).id + " - " + pqm.processosNegocio.processos.get(j).texto); int cont_cell = pqm.processosNegocio.processos.get(j).relacoes.size(); for (int x = 0; x < cont_cell; x++) { if (pqm.processosNegocio.processos.get(j).relacoes.get(x).estado == true) { tableRow.getCell(x + 1).setText("x"); contador++; } } cont_cell++; tableRow.getCell(cont_cell).setText(Integer.toString(contador)); cont_cell++; tableRow.getCell(cont_cell).setText(pqm.processosNegocio.processos.get(j).qualidadep); cont_cell++; if (pqm.processosNegocio.processos.get(j).gastador == true) { tableRow.getCell(cont_cell).setText("x"); } } paragraph = document.createParagraph(); run = paragraph.createRun(); run.setText("Tabela 1 - Analise dos FCS nos PN"); }
From source file:pqm.client.DocGenerator.java
public static void gerar_matriz1(XWPFDocument document) { /*criar matrizes*/ XWPFTable table1 = document.createTable(); XWPFTableRow tableRow = table1.getRow(0); tableRow.getCell(0).setText(" 4 "); for (int i = 3; i > 0; i--) { table1.createRow().getCell(0).setText(" " + Integer.toString(i) + " "); }//from www.j av a 2s . co m table1.createRow().getCell(0).setText(""); for (int i = 0; i <= 4; i++) { for (int j = 1; j <= 5; j++) { table1.getRow(i).addNewTableCell(); } } table1.getRow(4).getCell(1).setText(" E "); table1.getRow(4).getCell(2).setText(" D "); table1.getRow(4).getCell(3).setText(" C "); table1.getRow(4).getCell(4).setText(" B "); table1.getRow(4).getCell(5).setText(" A "); /*preencher matriz*/ teste t1 = new teste(); pqm = t1.escreve(); int tot_imp = 0; String qual; int qual_int = 0; String id_p; for (int p = 0; p < pqm.processosNegocio.processos.size(); p++) { for (int t = 0; t < pqm.processosNegocio.processos.get(p).relacoes.size(); t++) { if (pqm.processosNegocio.processos.get(p).relacoes.get(t).estado == true) tot_imp++; } qual = pqm.processosNegocio.processos.get(p).qualidadep; if (qual.equals("E") || qual.equals("e")) qual_int = 1; else if (qual.equals("D") || qual.equals("d")) qual_int = 2; if (qual.equals("C") || qual.equals("c")) qual_int = 3; if (qual.equals("B") || qual.equals("b")) qual_int = 4; if (qual.equals("A") || qual.equals("a")) qual_int = 5; id_p = pqm.processosNegocio.processos.get(p).id; System.out.println("tot_imp: " + tot_imp); table1.getRow(4 - tot_imp).getCell(qual_int).setText(id_p + " "); if (pqm.processosNegocio.processos.get(p).gastador == true) { proc_gastador.add(pqm.processosNegocio.processos.get(p).id); } if (4 - tot_imp == 4 && qual_int == 1 || qual_int == 2 || qual_int == 3) { proc_criticos.add(id_p); proc_criticos.add(pqm.processosNegocio.processos.get(p).texto); } else if (4 - tot_imp == 3 && qual_int == 1 || qual_int == 2) { proc_criticos.add(id_p); proc_criticos.add(pqm.processosNegocio.processos.get(p).texto); } else if (4 - tot_imp == 2 && qual_int == 1) { proc_criticos.add(id_p); proc_criticos.add(pqm.processosNegocio.processos.get(p).texto); } tot_imp = 0; } XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("Tabela 2 - Divisao dos Processos por nivel de importancia e criticidade"); }
From source file:pqm.client.DocGenerator.java
public static void tabela_importancia(XWPFDocument document) { /*criar tabela pn vs fcs */ XWPFTable table = document.createTable(); XWPFTableRow tableRowOne = table.getRow(0); tableRowOne.getCell(0).setText(""); /*tableRowOne.addNewTableCell().setText("FC1"); tableRowOne.addNewTableCell().setText("FC2");*/ teste t1 = new teste(); pqm = t1.escreve();/* w w w . j av a2s.c o m*/ /* ler fcs e colocar na tabela*/ int num_fcs = pqm.fcs.size(); for (int i = 0; i < num_fcs; i++) { tableRowOne.addNewTableCell().setText(pqm.fcs.get(i).texto); } /*criar analise */ for (int i = 0; i < 5; i++) { tableRowOne.addNewTableCell(); } /*escrever analise*/ tableRowOne.getCell(num_fcs + 1).setText("Tot. Imp"); tableRowOne.getCell(num_fcs + 2).setText("Qual. Proc."); tableRowOne.getCell(num_fcs + 3).setText("Proc. Gast"); tableRowOne.getCell(num_fcs + 4).setText("Qual. Neg."); tableRowOne.getCell(num_fcs + 5).setText("Qual. Tecn."); /*processos*/ for (int j = 0; j < pqm.processosNegocio.processos.size(); j++) { int contador = 0; XWPFTableRow tableRow = table.createRow(); tableRow.getCell(0).setText("" + pqm.processosNegocio.processos.get(j).id + " - " + pqm.processosNegocio.processos.get(j).texto); int cont_cell = pqm.processosNegocio.processos.get(j).relacoes.size(); for (int x = 0; x < cont_cell; x++) { if (pqm.processosNegocio.processos.get(j).relacoes.get(x).estado == true) { tableRow.getCell(x + 1).setText("x"); contador++; } } cont_cell++; tableRow.getCell(cont_cell).setText(Integer.toString(contador)); cont_cell++; tableRow.getCell(cont_cell).setText(pqm.processosNegocio.processos.get(j).qualidadep); cont_cell++; if (pqm.processosNegocio.processos.get(j).gastador == true) { tableRow.getCell(cont_cell).setText("x"); } cont_cell++; tableRow.getCell(cont_cell).setText(pqm.processosNegocio.processos.get(j).qualidaden); cont_cell++; tableRow.getCell(cont_cell).setText(pqm.processosNegocio.processos.get(j).qualidadet); } XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("Tabela 3 - Analise da importancia dos FCS nos PN e nas IT associadas"); }
From source file:pqm.client.DocGenerator.java
public static void gerar_matriz2(XWPFDocument document) { /*criar matrizes*/ XWPFTable table1 = document.createTable(); XWPFTableRow tableRow = table1.getRow(0); tableRow.getCell(0).setText(" A "); table1.createRow().getCell(0).setText(" B "); table1.createRow().getCell(0).setText(" C "); table1.createRow().getCell(0).setText(" D "); table1.createRow().getCell(0).setText(""); for (int i = 0; i <= 4; i++) { for (int j = 1; j <= 4; j++) { table1.getRow(i).addNewTableCell(); }/* ww w .ja v a 2 s . co m*/ } table1.getRow(4).getCell(1).setText(" D "); table1.getRow(4).getCell(2).setText(" C "); table1.getRow(4).getCell(3).setText(" B "); table1.getRow(4).getCell(4).setText(" A "); /*preencher matriz*/ teste t1 = new teste(); pqm = t1.escreve(); int qual_neg = 0; String qual_n; String qual_t; int qual_int = 0; String id_p; for (int p = 0; p < pqm.processosNegocio.processos.size(); p++) { qual_n = pqm.processosNegocio.processos.get(p).qualidaden; if (qual_n.equals("D") || qual_n.equals("d")) qual_neg = 3; else if (qual_n.equals("C") || qual_n.equals("c")) qual_neg = 2; if (qual_n.equals("B") || qual_n.equals("b")) qual_neg = 1; if (qual_n.equals("A") || qual_n.equals("a")) qual_neg = 0; qual_t = pqm.processosNegocio.processos.get(p).qualidadet; if (qual_t.equals("D") || qual_t.equals("d")) qual_int = 1; else if (qual_t.equals("C") || qual_t.equals("c")) qual_int = 2; if (qual_t.equals("B") || qual_t.equals("b")) qual_int = 3; if (qual_t.equals("A") || qual_t.equals("a")) qual_int = 4; id_p = pqm.processosNegocio.processos.get(p).id; table1.getRow(qual_neg).getCell(qual_int).setText(id_p + " "); if (qual_neg == 1 || qual_neg == 0 && qual_int == 1 || qual_int == 2) { proc_ti.add(id_p); proc_ti.add(pqm.processosNegocio.processos.get(p).texto); } qual_neg = 0; qual_int = 0; } XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("Tabela 4 - Divisao dos processos por nivel de criticidade"); }
From source file:pqm.client.DocGenerator.java
public static void gerar_conclusao(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("CONCLUSAO:"); paragraph = document.createParagraph(); run = paragraph.createRun();//from w w w . j a v a2 s . c o m run.setText("Apos uma analise das tabelas geradas podemos concluir que os processos mais criticos sao: "); paragraph = document.createParagraph(); run = paragraph.createRun(); for (int i = 0; i < proc_criticos.size(); i = i + 2) { run.setText(proc_criticos.get(i) + " - " + proc_criticos.get(i + 1)); paragraph = document.createParagraph(); run = paragraph.createRun(); } run.setText("Tambem podemos verificar quais os processos gastadores, que sao: "); for (int i = 0; i < proc_gastador.size(); i++) { if (i < proc_gastador.size() - 1) run.setText(proc_gastador.get(i) + ", "); else run.setText(proc_gastador.get(i) + "."); } paragraph = document.createParagraph(); run = paragraph.createRun(); run.setText("Por fim podemos verificar que os processos com as ti inadequadas sao: "); paragraph = document.createParagraph(); run = paragraph.createRun(); for (int i = 0; i < proc_ti.size(); i = i + 2) { run.setText(proc_ti.get(i) + " - " + proc_ti.get(i + 1)); paragraph = document.createParagraph(); run = paragraph.createRun(); } }
From source file:pqm.client.DocGenerator.java
public static void gerar_missao(XWPFDocument document) { XWPFParagraph paragraph = document.createParagraph(); XWPFRun run = paragraph.createRun(); run.setText("MISSAO:"); paragraph = document.createParagraph(); run = paragraph.createRun();/*from w w w. ja v a 2s. c o m*/ run.setText(pqm.missao.texto); }
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();// w ww. java 2 s.co m 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(); } }