/** * 重复样式 * * @param destRun 新建的run * @param srcRun 原始run */ public static void styleRun(XWPFRun destRun, XWPFRun srcRun) { if (null == destRun || null == srcRun) return; CTR ctr = srcRun.getCTR(); if (ctr.isSetRPr() && ctr.getRPr().isSetRStyle()){ String val = ctr.getRPr().getRStyle().getVal(); if (StringUtils.isNotBlank(val)) { CTRPr pr = destRun.getCTR().isSetRPr() ? destRun.getCTR().getRPr() : destRun.getCTR().addNewRPr(); CTString rStyle = pr.isSetRStyle() ? pr.getRStyle() : pr.addNewRStyle(); rStyle.setVal(val); } } if (Boolean.TRUE.equals(srcRun.isBold())) destRun.setBold(srcRun.isBold()); destRun.setColor(srcRun.getColor()); // destRun.setCharacterSpacing(srcRun.getCharacterSpacing()); if (StringUtils.isNotBlank(srcRun.getFontFamily())) destRun.setFontFamily(srcRun.getFontFamily()); int fontSize = srcRun.getFontSize(); if (-1 != fontSize) destRun.setFontSize(fontSize); if (Boolean.TRUE.equals(srcRun.isItalic())) destRun.setItalic(srcRun.isItalic()); if (Boolean.TRUE.equals(srcRun.isStrikeThrough())) destRun.setStrikeThrough(srcRun.isStrikeThrough()); destRun.setUnderline(srcRun.getUnderline()); }
Boolean strike = style.isStrike(); Boolean underLine = style.isUnderLine(); if (StringUtils.isNotBlank(color)) run.setColor(color); if (0 != fontSize) run.setFontSize(fontSize); if (StringUtils.isNotBlank(fontFamily)) {
run.setColor(toHex(forecolor.split(",")));
//add this para in first column to get table width, 84pts total private XWPFParagraph getFirstColumnText(){ XWPFParagraph para=new XWPFDocument().createParagraph(); XWPFRun run=para.createRun(); run.setColor("ffffff"); run.setText("..................................................................................."); return para; }
switch (wordsByElement.get(k)) { case "ahhh": //If word is ahhh run.setColor("ff5400"); //Set Color break; case "acca": //If word is acca run.setColor("a7bf42"); //set color break; case "adda": //So on run.setColor("7b8896"); //so forth break; case "hah": run.setColor("00adee"); break; default: //If word is not one of the above run.setColor("000000"); //Color is black break;
r.setColor("DC143C");
XWPFTableRow rowOne = table.getRow(0); XWPFParagraph paragraph = rowOne.getCell(0).addParagraph(); setRun(paragraphRefTitle.createRun() , "Calibre LIght" , 10, "2b5079" , "Some string" , false, false); private static void setRun (XWPFRun run , String fontFamily , int fontSize , String colorRGB , String text , boolean bold , boolean addBreak) { run.setFontFamily(fontFamily); run.setFontSize(fontSize); run.setColor(colorRGB); run.setText(text); run.setBold(bold); if (addBreak) run.addBreak(); }
f.setAccessible(true); Color c = (Color)f.get(as.getAttribute(attrib)); run.setColor(String.format("%1$02X%2$02X%3$02X", c.getRed(),c.getGreen(),c.getBlue())); } else if (CSS.Attribute.FONT_WEIGHT.equals(attrib)) { if ("bold".equals(as.getAttribute(attrib).toString())) {
newRun.setItalic( run.isItalic() ); newRun.setStrike( run.isStrike() ); newRun.setColor( run.getColor() );
newRun.setCapitalized(run.isCapitalized()); newRun.setColor(run.getColor()); newRun.setDoubleStrikethrough(run.isDoubleStrikeThrough()); newRun.setEmbossed(run.isEmbossed());
paragraphOneRunOne.setFontSize(20); paragraphOneRunOne.setFontFamily("Verdana"); paragraphOneRunOne.setColor("000070"); paragraphOneRunOne.setText("Daily Status Report"); paragraphTwoRunOne.setFontSize(12); paragraphTwoRunOne.setFontFamily("Verdana"); paragraphTwoRunOne.setColor("000070"); paragraphTwoRunOne.setText(date); paragraphTwoRunOne.addBreak(); paragraphThreeRunOne.setFontSize(14); paragraphThreeRunOne.setFontFamily("Verdana"); paragraphThreeRunOne.setColor("000070"); paragraphThreeRunOne.setText("5.30 AM PST"); paragraphThreeRunOne.addBreak(); paragraphFourRunOne.setFontSize(10); paragraphFourRunOne.setFontFamily("Verdana"); paragraphFourRunOne.setColor("000070"); paragraphFourRunOne.setText("ABCD"); paragraphFourRunOne.setFontSize(10); paragraphFourRunOne.setFontFamily("Verdana"); paragraphFourRunOne.setColor("000070"); paragraphFourRunOne.setText("ABCD00000000000");
tmpRun.setFontFamily("Calibri (Corps)"); tmpRun.setBold(true); tmpRun.setColor("003894"); tmpParagraph.setAlignment(ParagraphAlignment.CENTER); tmpRun.setUnderline(UnderlinePatterns.SINGLE);
run.setColor(toHex(forecolor.split(",")));
run.setItalic(refRun.isItalic()); run.setFontFamily(refRun.getFontFamily()); run.setColor(refRun.getColor()); if(refRun.getFontSize()>0){ run.setFontSize(refRun.getFontSize());
run.setItalic(refRun.isItalic()); run.setFontFamily(refRun.getFontFamily()); run.setColor(refRun.getColor()); run.setFontSize(refRun.getFontSize()); run.setStrike(refRun.isStrike());
ctshd.setFill(style.getBgColor()); if (style.getBgColor() != null) run.setColor(style.getTextColor()); if (style.getFontSize() > 0) run.setFontSize(style.getFontSize());
ctshd.setFill(style.getBgColor()); if (style.getBgColor() != null) run.setColor(style.getTextColor()); if (style.getFontSize() > 0) run.setFontSize(style.getFontSize());
run.setItalic(refRun.isItalic()); run.setFontFamily(refRun.getFontFamily()); run.setColor(refRun.getColor());
if(style.getUnderline()!=null)run.setUnderline(UnderlinePatterns.valueOf(style.getUnderline().name())); if(style.getTextColor()!=null)ctshd.setFill(style.getBgColor()); if(style.getBgColor()!=null)run.setColor(style.getTextColor()); if(style.getFontSize()>0)run.setFontSize(style.getFontSize()); run.setText(text==null?"":text);
cellR.setStrike(tmpR.isStrike()); cellR.setUnderline(tmpR.getUnderline()); cellR.setColor(tmpR.getColor()); cellR.setTextPosition(tmpR.getTextPosition()); if (tmpR.getFontSize() != -1) {