The attribute details of XWPFRun operations using POI in java, poixwpfrun
XWPFRun is a text object in XWPFDocument)
Create Document Object
XWPFDocument docxDocument = new XWPFDocument ();
Create paragraph object
XWPFParagraph paragraphX = docxDocument. createParagraph ();
Create a Text object (today's main character: XWPFRun)
XWPFRun runX = paragraphX. createRun ();
// Default value: (wps)/ (office2016. setText... "); runX. setBold (false); // bold runX. setCapitalized (false); // I do not know what this attribute is doing. // runX. setCharacterSpacing (5); // This attribute returns the error runX. setColor ("BED4F1"); // sets the color -- hexadecimal runX. setDoubleStrikethrough (false); // double strikethrough runX. setEmbossed (false); // embossed font-the effect is similar to that of the mark (floating shadow). // runX. setFontFamily (""); // font runX. setFontFamily (" 文 ", FontCharRange. cs); // font, range ---- effect unknown runX. setFontSize (14); // font size runX. setImprinted (false); // imprint (floating shadow) --- effect and relief are similar to runX. setItalic (false); // italic (font skew) // runX. setKerning (1); // padding adjustment ---- this seems to have no effect on runX. setShadow (true); // shadow --- slightly effect (the shadow is not obvious) // runX. setSmallCaps (true); // small stock ------ unclear effect // runX. setStrike (true); // Delete (discard) runX. setStrikeThrough (false); // strikethrough (new Strike) // runX. setSubscript (VerticalAlign. SUBSCRIPT); // SUBSCRIPT (now this run becomes a SUBSCRIPT) --- enumeration // runX. setTextPosition (5); // font position (unknown effect) // runX. setUnderline (UnderlinePatterns. DASH_LONG); // underlines of various types (enumeration)
// RunX0.addBreak (); // operations similar to line feed (html br tag)
RunX0.addTab (); // tab key
RunX0.addCarriageReturn (); // enter the key
Note: addTab () and addCarriageReturn () are related to the sequence in which setText () is used: for example, run addTab first and then write Text. This is the Table of the current Text, the opposite is the Tab effect for the next run Text.