Example usage for org.apache.poi.xwpf.usermodel XWPFRun setFontFamily

List of usage examples for org.apache.poi.xwpf.usermodel XWPFRun setFontFamily

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFRun setFontFamily.

Prototype

public void setFontFamily(String fontFamily) 

Source Link

Document

Specifies the fonts which shall be used to display the text contents of this run.

Usage

From source file:com.gezipu360.cashier.bean.word.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);/*from   w ww. j a v a 2s  . co  m*/
    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:com.glodon.tika.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);/*w  ww.  j  av  a2s . c  o m*/
    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.setStrikeThrough(true);
    r2.setFontSize(20);

    XWPFRun r3 = p2.createRun();
    r3.setText("and went away");
    r3.setStrikeThrough(true);
    r3.setFontSize(20);
    r3.setSubscript(VerticalAlign.SUPERSCRIPT);

    XWPFParagraph p3 = doc.createParagraph();
    p3.setWordWrapped(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();
    doc.close();
}

From source file:com.glodon.tika.SimpleTable.java

License:Apache License

public static void createSimpleTable() throws Exception {
    XWPFDocument doc = new XWPFDocument();

    try {/* w  ww.ja  v  a2s.c  o  m*/
        XWPFTable table = doc.createTable(3, 3);

        table.getRow(1).getCell(1).setText("EXAMPLE OF TABLE");

        // table cells have a list of paragraphs; there is an initial
        // paragraph created when the cell is created. If you create a
        // paragraph in the document to put in the cell, it will also
        // appear in the document following the table, which is probably
        // not the desired result.
        XWPFParagraph p1 = table.getRow(0).getCell(0).getParagraphs().get(0);

        XWPFRun r1 = p1.createRun();
        r1.setBold(true);
        r1.setText("The quick brown fox");
        r1.setItalic(true);
        r1.setFontFamily("Courier");
        r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
        r1.setTextPosition(100);

        table.getRow(2).getCell(2).setText("only text");

        OutputStream out = new FileOutputStream("simpleTable.docx");
        try {
            doc.write(out);
        } finally {
            out.close();
        }
    } finally {
        doc.close();
    }
}

From source file:com.glodon.tika.SimpleTable.java

License:Apache License

/**
 * Create a table with some row and column styling. I "manually" add the
 * style name to the table, but don't check to see if the style actually
 * exists in the document. Since I'm creating it from scratch, it obviously
 * won't exist. When opened in MS Word, the table style becomes "Normal".
 * I manually set alternating row colors. This could be done using Themes,
 * but that's left as an exercise for the reader. The cells in the last
 * column of the table have 10pt. "Courier" font.
 * I make no claims that this is the "right" way to do it, but it worked
 * for me. Given the scarcity of XWPF examples, I thought this may prove
 * instructive and give you ideas for your own solutions.
        //from   w ww . j a va2  s. com
 * @throws Exception
 */
public static void createStyledTable() throws Exception {
    // Create a new document from scratch
    XWPFDocument doc = new XWPFDocument();

    try {
        // -- OR --
        // open an existing empty document with styles already defined
        //XWPFDocument doc = new XWPFDocument(new FileInputStream("base_document.docx"));

        // Create a new table with 6 rows and 3 columns
        int nRows = 6;
        int nCols = 3;
        XWPFTable table = doc.createTable(nRows, nCols);

        // Set the table style. If the style is not defined, the table style
        // will become "Normal".
        CTTblPr tblPr = table.getCTTbl().getTblPr();
        CTString styleStr = tblPr.addNewTblStyle();
        styleStr.setVal("StyledTable");

        // Get a list of the rows in the table
        List<XWPFTableRow> rows = table.getRows();
        int rowCt = 0;
        int colCt = 0;
        for (XWPFTableRow row : rows) {
            // get table row properties (trPr)
            CTTrPr trPr = row.getCtRow().addNewTrPr();
            // set row height; units = twentieth of a point, 360 = 0.25"
            CTHeight ht = trPr.addNewTrHeight();
            ht.setVal(BigInteger.valueOf(360));

            // get the cells in this row
            List<XWPFTableCell> cells = row.getTableCells();
            // add content to each cell
            for (XWPFTableCell cell : cells) {
                // get a table cell properties element (tcPr)
                CTTcPr tcpr = cell.getCTTc().addNewTcPr();
                // set vertical alignment to "center"
                CTVerticalJc va = tcpr.addNewVAlign();
                va.setVal(STVerticalJc.CENTER);

                // create cell color element
                CTShd ctshd = tcpr.addNewShd();
                ctshd.setColor("auto");
                ctshd.setVal(STShd.CLEAR);
                if (rowCt == 0) {
                    // header row
                    ctshd.setFill("A7BFDE");
                } else if (rowCt % 2 == 0) {
                    // even row
                    ctshd.setFill("D3DFEE");
                } else {
                    // odd row
                    ctshd.setFill("EDF2F8");
                }

                // get 1st paragraph in cell's paragraph list
                XWPFParagraph para = cell.getParagraphs().get(0);
                // create a run to contain the content
                XWPFRun rh = para.createRun();
                // style cell as desired
                if (colCt == nCols - 1) {
                    // last column is 10pt Courier
                    rh.setFontSize(10);
                    rh.setFontFamily("Courier");
                }
                if (rowCt == 0) {
                    // header row
                    rh.setText("header row, col " + colCt);
                    rh.setBold(true);
                    para.setAlignment(ParagraphAlignment.CENTER);
                } else {
                    // other rows
                    rh.setText("row " + rowCt + ", col " + colCt);
                    para.setAlignment(ParagraphAlignment.LEFT);
                }
                colCt++;
            } // for cell
            colCt = 0;
            rowCt++;
        } // for row

        // write the file
        OutputStream out = new FileOutputStream("styledTable.docx");
        try {
            doc.write(out);
        } finally {
            out.close();
        }
    } finally {
        doc.close();
    }
}

From source file:com.siemens.sw360.licenseinfo.outputGenerators.DocxUtils.java

License:Open Source License

private static void addFormattedText(XWPFRun run, String text, String fontFamily, int fontSize, boolean bold) {
    run.setFontSize(fontSize);//from  ww  w. j  av  a  2 s.c om
    run.setFontFamily(fontFamily);
    run.setBold(bold);
    run.setText(text);
}

From source file:de.knowwe.include.export.DefaultBuilder.java

License:Open Source License

private XWPFRun append(String text, XWPFRun run) {
    if (bold)//from   w  w w.  ja  v a  2  s .c  o m
        run.setBold(true);
    if (italic)
        run.setItalic(true);
    if (code)
        run.setFontFamily("Courier New");
    run.setText(text);
    return run;
}

From source file:edu.cqupt.test.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);//w w w .j av a  2  s .  c  o m
    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("??? " + "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("F://simple.docx");
    doc.write(out);
    out.close();

}

From source file:eremeykin.pete.reports.ui.ReportAction.java

@Override
public void actionPerformed(ActionEvent e) {
    resultChanged(null);/*from  ww  w .jav  a 2 s . co m*/
    if (model == null) {
        return;
    }

    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setVerticalAlignment(TextAlignment.TOP);

    XWPFRun r1 = p1.createRun();
    r1.setBold(true);
    r1.setText("");
    r1.setBold(true);
    r1.setFontFamily("Times New Roman");
    r1.setFontSize(24);
    r1.setTextPosition(10);

    XWPFParagraph p2 = doc.createParagraph();
    p2.setAlignment(ParagraphAlignment.LEFT);
    p2.setVerticalAlignment(TextAlignment.CENTER);
    XWPFRun r2 = p2.createRun();
    r2.setText(" ? : ");
    r2.setBold(false);
    r2.setFontFamily("Times New Roman");
    r2.setFontSize(14);
    r2.setTextPosition(10);

    XWPFTable table = doc.createTable(1, 2);
    table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(9000));
    ModelParameter root = model.getRoot();

    int row = 1;
    Map.Entry<ModelParameter, Integer> kv = model.getParameterAndLevelByID(root, 0);
    ModelParameter parameter = kv.getKey();
    Integer level = kv.getValue();

    ArrayList<Integer> ids = new ArrayList(model.asMap().keySet());
    Collections.sort(ids);
    for (Integer each : ids) {
        table.createRow();
        String text = "";
        kv = model.getParameterAndLevelByID(root, each);
        parameter = kv.getKey();
        level = kv.getValue();
        for (int c = 0; c < level; c++) {
            text += "        ";
        }
        table.getRow(row - 1).getCell(0).setText(text + parameter.toString());
        table.getRow(row - 1).getCell(1).setText(parameter.getValue());
        row++;
    }
    table.setWidth(80);

    XWPFParagraph p3 = doc.createParagraph();
    p3.setAlignment(ParagraphAlignment.LEFT);
    p3.setVerticalAlignment(TextAlignment.CENTER);
    XWPFRun r3 = p3.createRun();
    r3.addBreak();
    r3.setText("\n : ");
    r3.setBold(false);
    r3.setFontFamily("Times New Roman");
    r3.setFontSize(14);

    File uPlotFile = new File(WorkspaceManager.INSTANCE.getWorkspace().getAbsolutePath() + "/uplot.png");
    try {
        byte[] picbytes = IOUtils.toByteArray(new FileInputStream(uPlotFile));
        doc.addPictureData(picbytes, XWPFDocument.PICTURE_TYPE_PNG);
        XWPFRun pr = doc.createParagraph().createRun();
        pr.addPicture(new FileInputStream(uPlotFile), Document.PICTURE_TYPE_PNG, "plot.png", Units.toEMU(450),
                Units.toEMU(337));
        pr.addCarriageReturn();
        pr.addBreak(BreakType.PAGE);
        pr.addBreak(BreakType.TEXT_WRAPPING);

    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }

    XWPFParagraph p4 = doc.createParagraph();
    p4.setAlignment(ParagraphAlignment.LEFT);
    p4.setVerticalAlignment(TextAlignment.CENTER);
    XWPFRun r4 = p4.createRun();
    r4.addBreak();
    r4.setText("\n ?: ");
    r4.setBold(false);
    r4.setFontFamily("Times New Roman");
    r4.setFontSize(14);

    File sPlotFile = new File(WorkspaceManager.INSTANCE.getWorkspace().getAbsolutePath() + "/splot.png");
    try {
        byte[] picbytes = IOUtils.toByteArray(new FileInputStream(sPlotFile));
        doc.addPictureData(picbytes, XWPFDocument.PICTURE_TYPE_PNG);
        XWPFParagraph pp = doc.createParagraph();
        pp.createRun().addPicture(new FileInputStream(sPlotFile), Document.PICTURE_TYPE_PNG, "plot.png",
                Units.toEMU(450), Units.toEMU(337));
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }

    File reportFile = new File("report.docx");
    try (FileOutputStream out = new FileOutputStream(reportFile)) {
        doc.write(out);
        if (Desktop.isDesktopSupported()) {
            Desktop.getDesktop().edit(reportFile);
        } else {
        }

    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:export.TableFunctionalReq.java

protected static void createReqFuncTable(XWPFDocument doc, FunctionalRequirement funcReq) {

    int[] cols = { 2943, 6507 };

    XWPFTable rf = doc.createTable(9, 2);

    // Get a list of the rows in the table
    List<XWPFTableRow> rows = rf.getRows();
    int rowCt = 0;
    int colCt = 0;

    for (XWPFTableRow row : rows) {

        // get the cells in this row
        List<XWPFTableCell> cells = row.getTableCells();
        for (XWPFTableCell cell : cells) {
            // get a table cell properties element (tcPr)
            CTTcPr tcpr = cell.getCTTc().addNewTcPr();

            // create cell color element
            CTShd ctshd = tcpr.addNewShd();

            ctshd.setColor("auto");
            ctshd.setVal(STShd.CLEAR);// w w w  . j a v a2s. c  o m

            if (colCt == 0) {
                ctshd.setFill("5C7F92");
            }

            // get 1st paragraph in cell's paragraph list
            XWPFParagraph para = cell.getParagraphs().get(0);
            para.setStyle("AltranNormal");
            para.setSpacingAfter(120);
            para.setSpacingBefore(120);

            // create a run to contain the content
            XWPFRun rh = para.createRun();
            //rh.setFontSize(11);

            rh.setFontFamily("Lucida Sans Unicode");

            if (colCt == 0) {
                rh.setColor("FFFFFF");
            }

            if (rowCt == 0 && colCt == 0) {
                rh.setText("RF " + ((x < 9) ? "0" + x : x) + "- F");
                x++;
            } else if (rowCt == 1 && colCt == 0) {
                rh.setText("Use Case (se disponvel):");
            } else if (rowCt == 2 && colCt == 0) {
                rh.setText("Descrio:");
            } else if (rowCt == 3 && colCt == 0) {
                rh.setText("Fonte:");
            } else if (rowCt == 4 && colCt == 0) {
                rh.setText("Fundamento:");
            } else if (rowCt == 5 && colCt == 0) {
                rh.setText("Critrio de avaliao:");
            } else if (rowCt == 6 && colCt == 0) {
                rh.setText("Satisfao do cliente:");
            } else if (rowCt == 7 && colCt == 0) {
                rh.setText("Insatisfao do cliente:");
            } else if (rowCt == 8 && colCt == 0) {
                rh.setText("Histrico:");
            }

            if (rowCt == 0 && colCt == 1) {// Nome do requisito
                rh.setText(funcReq.getName());
                rh.setBold(true);
            } else if (rowCt == 1 && colCt == 1) { // UseCases
                String testUC = "";
                int cntUC = 0;
                for (UseCase uc : funcReq.getUseCaseCollection()) {

                    if (cntUC == 0) {
                        testUC = uc.getName();
                    } else {
                        testUC = testUC + ", " + uc.getName();
                    }
                    cntUC++;
                }

                rh.setText(testUC);
            } else if (rowCt == 2 && colCt == 1) {// Descrio
                rh.setText(funcReq.getDescription());
            } else if (rowCt == 3 && colCt == 1) {// Fonte
                rh.setText(funcReq.getSource());
            } else if (rowCt == 4 && colCt == 1) {// Fundamento
                rh.setText(funcReq.getReason());
            } else if (rowCt == 5 && colCt == 1) {// Criterio de Avalicao
                rh.setText(funcReq.getAvaliationCriteria());
            } else if (rowCt == 6 && colCt == 1) {// Prioridade
                rh.setText(funcReq.getClientPriority().toString());
            } else if (rowCt == 7 && colCt == 1) {// Insatisfao
                rh.setText(funcReq.getClientInsatisfaction().toString());
            } else if (rowCt == 8 && colCt == 1) {// Historico
                rh.setText("Histrico");
            }

            cell.getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(cols[colCt]));
            colCt++;
        }
        colCt = 0;
        rowCt++;

    }

    doc.createParagraph().createRun().addBreak();

}

From source file:fr.opensagres.poi.xwpf.converter.xhtml.internal.XHTMLMapper.java

License:Open Source License

@Override
protected void visitStyleText(XWPFRun run, String text) throws Exception {
    if (run.getFontFamily() == null) {
        run.setFontFamily(getStylesDocument().getFontFamilyAscii(run));
    }//from  ww  w .  j a  v  a  2  s .  co m

    if (run.getFontSize() <= 0) {
        run.setFontSize(getStylesDocument().getFontSize(run).intValue());
    }

    CTRPr rPr = run.getCTR().getRPr();

    // 1) create attributes

    // 1.1) Create "class" attributes.
    AttributesImpl runAttributes = createClassAttribute(currentParagraph.getStyleID());

    // 1.2) Create "style" attributes.
    CSSStyle cssStyle = getStylesDocument().createCSSStyle(rPr);
    if (cssStyle != null) {
        Color color = RunTextHighlightingValueProvider.INSTANCE.getValue(rPr, getStylesDocument());
        if (color != null)
            cssStyle.addProperty(CSSStylePropertyConstants.BACKGROUND_COLOR, StringUtils.toHexString(color));
        if (Boolean.TRUE.equals(RunFontStyleStrikeValueProvider.INSTANCE.getValue(rPr, getStylesDocument()))
                || rPr.getDstrike() != null)
            cssStyle.addProperty("text-decoration", "line-through");
        if (rPr.getVertAlign() != null) {
            int align = rPr.getVertAlign().getVal().intValue();
            if (STVerticalAlignRun.INT_SUPERSCRIPT == align) {
                cssStyle.addProperty("vertical-align", "super");
            } else if (STVerticalAlignRun.INT_SUBSCRIPT == align) {
                cssStyle.addProperty("vertical-align", "sub");
            }
        }
    }
    runAttributes = createStyleAttribute(cssStyle, runAttributes);
    if (runAttributes != null) {
        startElement(SPAN_ELEMENT, runAttributes);
    }
    if (StringUtils.isNotEmpty(text)) {
        // Escape with HTML characters
        characters(StringEscapeUtils.escapeHtml(text));
    }
    if (runAttributes != null) {
        endElement(SPAN_ELEMENT);
    }
}