本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFDocument.createParagraph()
方法的一些代码示例,展示了XWPFDocument.createParagraph()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFDocument.createParagraph()
方法的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFDocument
类名称:XWPFDocument
方法名:createParagraph
[英]Appends a new paragraph to this document
[中]在本文件后面加上一个新段落
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument();
XWPFParagraph tmpParagraph = document.createParagraph();
XWPFRun tmpRun = tmpParagraph.createRun();
tmpRun.setText("LALALALAALALAAAA");
tmpRun.setFontSize(18);
document.write(new FileOutputStream(new File("yourpathhere")));
document.close();
代码示例来源:origin: looly/hutool
/**
* 增加一个段落
*
* @param align 段落对齐方式{@link ParagraphAlignment}
* @param font 字体信息{@link Font}
* @param texts 段落中的文本,支持多个文本作为一个段落
* @return this
*/
public Word07Writer addText(ParagraphAlignment align, Font font, String... texts) {
final XWPFParagraph p = this.doc.createParagraph();
if (null != align) {
p.setAlignment(align);
}
if (ArrayUtil.isNotEmpty(texts)) {
XWPFRun run;
for (String text : texts) {
run = p.createRun();
run.setText(text);
if (null != font) {
run.setFontFamily(font.getFamily());
run.setFontSize(font.getSize());
run.setBold(font.isBold());
run.setItalic(font.isItalic());
}
}
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 增加一个段落
*
* @param align 段落对齐方式{@link ParagraphAlignment}
* @param font 字体信息{@link Font}
* @param texts 段落中的文本,支持多个文本作为一个段落
* @return this
*/
public Word07Writer addText(ParagraphAlignment align, Font font, String... texts) {
final XWPFParagraph p = this.doc.createParagraph();
if (null != align) {
p.setAlignment(align);
}
if (ArrayUtil.isNotEmpty(texts)) {
XWPFRun run;
for (String text : texts) {
run = p.createRun();
run.setText(text);
if (null != font) {
run.setFontFamily(font.getFamily());
run.setFontSize(font.getSize());
run.setBold(font.isBold());
run.setItalic(font.isItalic());
}
}
}
return this;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* This method is used to create template for chart XML
* no need to read MS-Word file and modify charts
*
* @param width width of chart in document
* @param height height of chart in document
* @return This method return object of XWPFChart
* @throws InvalidFormatException
* @throws IOException
* @since POI 4.0.0
*/
public XWPFChart createChart(int width, int height) throws InvalidFormatException, IOException {
//get chart number
int chartNumber = getNextPartNumber(XWPFRelation.CHART, charts.size() + 1);
//create relationship in document for new chart
RelationPart rp = createRelationship(
XWPFRelation.CHART, XWPFFactory.getInstance(), chartNumber, false);
// initialize xwpfchart object
XWPFChart xwpfChart = rp.getDocumentPart();
xwpfChart.setChartIndex(chartNumber);
xwpfChart.attach(rp.getRelationship().getId(), createParagraph().createRun());
xwpfChart.setChartBoundingBox(width, height);
//add chart object to chart list
charts.add(xwpfChart);
return xwpfChart;
}
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument(new FileInputStream("template.docx");
paragraph = document.createParagraph();
paragraph.setStyle("Heading1");
代码示例来源:origin: youseries/ureport
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setFontSize(0);
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument(is);
...
XWPFParagraph paragraph = document.createParagraph();
paragraph.setPageBreak(true);
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument(new FileInputStream("template.docx");
paragraph = document.createParagraph();
lastParagraph.setStyle("Heading1");
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument(is);
...
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.addBreak(BreakType.PAGE);
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument(is);
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.addBreak(BreakType.PAGE);
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument();
...
XWPFParagraph paragraph = document.createParagraph();
paragraph.setPageBreak(true);
代码示例来源:origin: stackoverflow.com
private void changeOrientation(XWPFDocument document, String orientation){
CTDocument1 doc = document.getDocument();
CTBody body = doc.getBody();
CTSectPr section = body.addNewSectPr();
XWPFParagraph para = document.createParagraph();
CTP ctp = para.getCTP();
CTPPr br = ctp.addNewPPr();
br.setSectPr(section);
CTPageSz pageSize = section.getPgSz();
if(orientation.equals("landscape")){
pageSize.setOrient(STPageOrientation.LANDSCAPE);
pageSize.setW(BigInteger.valueOf(842 * 20));
pageSize.setH(BigInteger.valueOf(595 * 20));
}
else{
pageSize.setOrient(STPageOrientation.PORTRAIT);
pageSize.setH(BigInteger.valueOf(842 * 20));
pageSize.setW(BigInteger.valueOf(595 * 20));
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument();
XWPFParagraph tmpParagraph = document.createParagraph();
XWPFRun tmpRun = tmpParagraph.createRun();
tmpRun.setText("LALALALAALALAAAA");
tmpRun.setFontSize(18);
document.write(new FileOutputStream(new File("yourpathhere")));
代码示例来源:origin: stackoverflow.com
XWPFDocument newDoc = new XWPFDocument(); //Doc to write new doc to
XWPFParagraph para = newDoc.createParagraph(); //Paragraph
XWPFRun run = para.createRun(); //Where the text will be written from
run.setText("\t");
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument();
XWPFParagraph title = doc.createParagraph();
XWPFRun run = title.createRun();
run.setText("Fig.1 A Natural Scene");
run.setBold(true);
title.setAlignment(ParagraphAlignment.CENTER);
String imgFile = "encabezado.jpg"
FileInputStream is = new FileInputStream(imgFile);
run.addBreak();
run.addPicture(is, XWPFDocument.PICTURE_TYPE_JPEG, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels
is.close();
FileOutputStream fos = new FileOutputStream("test4.docx");
doc.write(fos);
fos.close();
代码示例来源:origin: stackoverflow.com
XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));
XWPFDocument doc = new XWPFDocument();
// let's copy styles from template to new doc
XWPFStyles newStyles = doc.createStyles();
newStyles.setStyles(template.getStyle());
XWPFParagraph para = doc.createParagraph();
para.setStyle("Heading1");
XWPFRun run = para.createRun();
run.setText("Heading 1");
return doc;
代码示例来源:origin: stackoverflow.com
ExtendedProperties ep = document.getProperties().getExtendedProperties();
int numberOfLines = ep.getUnderlyingProperties().getLines());
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun(); //create new run Page n
run.setText("TITLE");
<br>
//……………………………Your Logic here……………………………//
run.addCarriageReturn(); //separate previous text from break
run.addBreak(BreakType.PAGE); //Break the page
run.addBreak(BreakType.WORD_WRAPPING); //cancels effect of page break
WXPFRun run2 = paragraph.createRun(); //create a new run for pane n+1
</br>
代码示例来源:origin: stackoverflow.com
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("TITLE");
run.addCarriageReturn();
run.setText("some text and stuff here");
run.addCarriageReturn(); //separate previous text from break
run.addBreak(BreakType.PAGE);
run.addBreak(BreakType.WORD_WRAPPING); //cancels effect of page break
WXPFRun run2 = paragraph.createRun(); //create new run
run2.setText("more text");
run2.addCarriageReturn();
run2.setText("one more line");
代码示例来源:origin: stackoverflow.com
private void createParagraphs(XWPFParagraph p, String[] paragraphs) {
if (p != null) {
XWPFDocument doc = p.getDocument();
XmlCursor cursor = p.getCTP().newCursor();
for (int i = 0; i < paragraphs.length; i++) {
XWPFParagraph newP = doc.createParagraph();
newP.getCTP().setPPr(p.getCTP().getPPr());
XWPFRun newR = newP.createRun();
newR.getCTR().setRPr(p.getRuns().get(0).getCTR().getRPr());
newR.setText(paragraphs[i]);
XmlCursor c2 = newP.getCTP().newCursor();
c2.moveXml(cursor);
c2.dispose();
}
cursor.removeXml(); // Removes replacement text paragraph
cursor.dispose();
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p1 = doc.createParagraph();
p1.setAlignment(ParagraphAlignment.CENTER);
p1.setBorderBottom(Borders.DOUBLE);
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);
内容来源于网络,如有侵权,请联系作者删除!