List of usage examples for org.apache.poi.xwpf.usermodel XWPFRun setFontSize
@Override public void setFontSize(int size)
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
/** * Head 1 Title/*ww w . j ava 2s. co m*/ * * @param h1 * @param text */ public void textHead1Title(XWPFParagraph h1, String text) { h1.setAlignment(ParagraphAlignment.BOTH); XWPFRun h1Run = h1.createRun(); this.addParagraphTextBreak(h1Run, text); h1Run.setColor(TITLE_FONT_COLOR); h1Run.setBold(true); h1Run.setFontFamily(FONT_TYPE); h1Run.setFontSize(16); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textHead2Title(XWPFParagraph h2, String text) { h2.setAlignment(ParagraphAlignment.BOTH); XWPFRun h2Run = h2.createRun(); this.addParagraphTextBreak(h2Run, text); h2Run.setColor(TITLE_FONT_COLOR);/* w ww.j a v a 2s .co m*/ h2Run.setBold(true); h2Run.setFontFamily(FONT_TYPE); h2Run.setFontSize(14); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textHead3Title(XWPFParagraph h2, String text) { h2.setAlignment(ParagraphAlignment.BOTH); XWPFRun h2Run = h2.createRun(); this.addParagraphTextBreak(h2Run, text); h2Run.setColor(TITLE_FONT_COLOR);//from w w w . ja v a2 s. c o m h2Run.setBold(true); h2Run.setFontFamily(FONT_TYPE); h2Run.setFontSize(12); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textHeadCoverTitle(XWPFParagraph h1, String text) { h1.setAlignment(ParagraphAlignment.CENTER); XWPFRun h1Run = h1.createRun(); this.addParagraphTextBreak(h1Run, text); h1Run.setColor(TEXT_FONT_COLOR);/*from w ww . j a v a 2 s . c om*/ h1Run.setBold(false); h1Run.setFontFamily(FONT_TYPE); h1Run.setFontSize(26); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textNotes(XWPFParagraph paragraph, String text) { paragraph.setAlignment(ParagraphAlignment.BOTH); XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, text); paragraphRun.setColor(TEXT_FONT_COLOR); paragraphRun.setBold(false);/* ww w .jav a 2 s .c o m*/ paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(10); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textParagraph(XWPFParagraph paragraph, String text) { paragraph.setAlignment(ParagraphAlignment.BOTH); XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, text); paragraphRun.setColor(TEXT_FONT_COLOR); paragraphRun.setBold(false);/*from w w w . j av a2 s . c om*/ paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(11); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
public void textTable(XWPFDocument document, List<List<POIField>> sHeaders, List<List<POIField>> sData, Boolean highlightFirstColumn, String tableType) { XWPFTable table = document.createTable(); int record = 0; int headerIndex = 0; for (List<POIField> poiParameters : sHeaders) { // Setting the Header XWPFTableRow tableRowHeader;/*from w w w . ja va 2 s .co m*/ if (headerIndex == 0) { tableRowHeader = table.getRow(0); } else { tableRowHeader = table.createRow(); } for (POIField poiParameter : poiParameters) { // Condition for table b cell color in fields 5 and 6 if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) { TABLE_HEADER_FONT_COLOR = "DEEAF6"; } else { TABLE_HEADER_FONT_COLOR = "FFF2CC"; } if (headerIndex == 0) { if (record == 0) { XWPFParagraph paragraph = tableRowHeader.getCell(0).addParagraph(); paragraph.setAlignment(poiParameter.getAlignment()); XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, poiParameter.getText()); paragraphRun.setColor(TEXT_FONT_COLOR); if (poiParameter.getBold() != null) { paragraphRun.setBold(poiParameter.getBold()); } else { paragraphRun.setBold(true); } paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE); tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR); } else { XWPFParagraph paragraph = tableRowHeader.createCell().addParagraph(); paragraph.setAlignment(poiParameter.getAlignment()); XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, poiParameter.getText()); paragraphRun.setColor(TEXT_FONT_COLOR); if (poiParameter.getBold() != null) { paragraphRun.setBold(poiParameter.getBold()); } else { paragraphRun.setBold(true); } paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE); tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR); } } else { XWPFParagraph paragraph = tableRowHeader.getCell(record).addParagraph(); paragraph.setAlignment(poiParameter.getAlignment()); XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, poiParameter.getText()); paragraphRun.setColor(TEXT_FONT_COLOR); if (poiParameter.getBold() != null) { paragraphRun.setBold(poiParameter.getBold()); } else { paragraphRun.setBold(true); } paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE); tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR); } record++; } headerIndex++; record = 0; } for (List<POIField> poiParameters : sData) { record = 0; // Condition for table b cell color in fields 5 and 6 if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) { TABLE_HEADER_FONT_COLOR = "DEEAF6"; } else { TABLE_HEADER_FONT_COLOR = "FFF2CC"; } XWPFTableRow dataRow = table.createRow(); for (POIField poiParameter : poiParameters) { count++; XWPFParagraph paragraph = dataRow.getCell(record).addParagraph(); paragraph.setAlignment(poiParameter.getAlignment()); // Hyperlink if (poiParameter.getUrl() != null && !poiParameter.getUrl().isEmpty()) { this.textHyperlink(poiParameter.getUrl(), poiParameter.getText(), paragraph); } else { XWPFRun paragraphRun = paragraph.createRun(); this.addParagraphTextBreak(paragraphRun, poiParameter.getText()); if (poiParameter.getFontColor() != null) { paragraphRun.setColor(poiParameter.getFontColor()); } else { paragraphRun.setColor(TEXT_FONT_COLOR); } paragraphRun.setFontFamily(FONT_TYPE); paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE); // Condition for table b cell color in fields 5 and 6 if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) { TABLE_HEADER_FONT_COLOR = "DEEAF6"; dataRow.getCell(record).setColor("DEEAF6"); } else { TABLE_HEADER_FONT_COLOR = "FFF2CC"; } // highlight and bold first and SecondColumn for table D1 if (tableType.equals("tableD1AnnualReport") && (record == 0 || record == 1) && count < 9) { dataRow.getCell(record).setColor("DEEAF6"); paragraphRun.setBold(true); } else if (tableType.equals("tableD1AnnualReport") && count >= 9 && (record == 0 || record == 1)) { dataRow.getCell(record).setColor("E2EFD9"); paragraphRun.setBold(true); } else { if (highlightFirstColumn && record == 0) { dataRow.getCell(record).setColor(TABLE_HEADER_FONT_COLOR); if (poiParameter.getBold() != null) { paragraphRun.setBold(poiParameter.getBold()); } else { paragraphRun.setBold(true); } } else { if (poiParameter.getBold() != null) { paragraphRun.setBold(poiParameter.getBold()); } else { paragraphRun.setBold(false); } } } } record++; } } switch (tableType) { case "tableA": this.tableAStyle(table); break; case "tableE": this.tableEStyle(table); break; case "tableC": this.tableCStyle(table); break; case "tableF": this.tableFStyle(table); break; case "tableG": this.tableGStyle(table); break; case "tableAAnnualReport": this.tableBAnnualReportStyle(table); break; case "tableA1AnnualReport": this.tableA1AnnualReportStyle(table); break; case "tableA2AnnualReport": this.tableA1AnnualReportStyle(table); break; case "tableBAnnualReport": this.tableBAnnualReportStyle(table); break; case "tableCAnnualReport": count = 0; this.tableCStyle(table); break; case "tableD1AnnualReport": this.tableD1AnnualReportStyle(table); break; case "tableD2AnnualReport": count = 0; this.tableAStyle(table); break; case "tableEAnnualReport": this.tableGStyle(table); break; case "tableFAnnualReport": this.tableFStyle(table); break; case "tableGAnnualReport": this.tableGStyle(table); break; case "tableHAnnualReport": this.tableGStyle(table); break; case "tableIAnnualReport": this.tableIAnnualReportStyle(table); break; case "tableJAnnualReport": this.tableJAnnualReportStyle(table); break; } if (tableType.contains("AnnualReport")) { table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(13350)); } else { table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(12000)); } }
From source file:org.eclipse.sw360.licenseinfo.outputGenerators.DocxUtils.java
License:Open Source License
public static void addFormattedText(XWPFRun run, String text, String fontFamily, int fontSize, boolean bold, String rrggbbColor) {// w w w .j a v a2 s .c o m run.setFontSize(fontSize); run.setFontFamily(fontFamily); run.setBold(bold); if (rrggbbColor != null) { run.setColor(rrggbbColor); } setText(run, text); }
From source file:org.hackthelegacy.hack400tool.ibmiscannercore.IBMiConnector.java
License:Open Source License
public void exportToDOCX(String fileName, String inputText) { System.out.println("Save as file: " + fileName); try {/*w w w. ja va 2 s. com*/ prepareFile(fileName); FileOutputStream fileOutStream = new FileOutputStream(fileName); XWPFDocument wordDocument = new XWPFDocument(); String[] textArray = inputText.split("\n"); for (String textLine : textArray) { if (textLine.length() == 0 || textLine == null) continue; XWPFParagraph tmpParagraph = wordDocument.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); tmpRun.setText(textLine); tmpRun.setFontSize(8); tmpRun.setFontFamily("Courier New"); } wordDocument.write(fileOutStream); fileOutStream.close(); } catch (Exception ex) { Logger.getLogger(IBMiConnector.class.getName()).log(Level.SEVERE, null, ex); return; } }
From source file:org.obeonetwork.m2doc.generator.M2DocEvaluator.java
License:Open Source License
/** * Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs. * /*w ww. j a va2s . c om*/ * @param run * The run to style * @param style * The style to apply, can be <code>null</code> */ private void applyMStyle(XWPFRun run, MStyle style) { if (style.getFontSize() != -1) { run.setFontSize(style.getFontSize()); } if (style.getFontModifiers() != -1) { run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0); run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0); if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) { run.setUnderline(UnderlinePatterns.SINGLE); } run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0); } if (style.getForegroundColor() != null) { run.setColor(hexColor(style.getForegroundColor())); } }