📅  最后修改于: 2020-11-18 08:55:12             🧑  作者: Mango
本章将带您了解用于管理Word文档的Apache POI的类和方法。
这是一个标记器接口(该接口不包含任何方法),用于通知实现的类可以创建Word文档。
这是org.apache.poi.xwpf.usermodel包下的类。它用于创建.docx文件格式的MS-Word文档。
Sr.No. | Method & Description |
---|---|
1 |
commit() Commits and saves the document. |
2 |
createParagraph() Appends a new paragraph to this document. |
3 |
createTable() Creates an empty table with one row and one column as default. |
4 |
createTOC() Creates a table of content for Word document. |
5 |
getParagraphs() Returns the paragraph(s) that holds the text of the header or footer. |
6 |
getStyle() Returns the styles object used. |
有关此类的其余方法,请参阅位于以下位置的完整API文档:
软件包org.apache.poi.openxml4j.opc.internal 。
这是org.apache.poi.xwpf.usermodel包下的类,用于在Word文档中创建段落。此实例还用于将所有类型的元素添加到Word文档中。
Sr.No. | Method & Description |
---|---|
1 |
createRun() Appends a new run to this paragraph. |
2 |
getAlignment() Returns the paragraph alignment which shall be applied to the text in this paragraph. |
3 |
setAlignment(ParagraphAlignment align) Specifies the paragraph alignment which shall be applied to the text in this paragraph. |
4 |
setBorderBottom(Borders border) Specifies the border which shall be displayed below a set of paragraphs, which have the same set of paragraph border settings. |
5 |
setBorderLeft(Borders border) Specifies the border which shall be displayed on the left side of the page around the specified paragraph. |
6 |
setBorderRight(Borders border) Specifies the border which shall be displayed on the right side of the page around the specified paragraph. |
7 |
setBorderTop(Borders border) Specifies the border which shall be displayed above a set of paragraphs which have the same set of paragraph border settings. |
有关此类的其余方法,请参阅位于以下位置的完整API文档:
这是org.apache.poi.xwpf.usermodel包下的类,用于向段落添加文本区域。
Sr.No. | Method & Description |
---|---|
1 |
addBreak() Specifies that a break shall be placed at the current location in the run content. |
2 |
addTab() Specifies that a tab shall be placed at the current location in the run content. |
3 |
setColor(java.lang.String rgbStr) Sets text color. |
4 |
setFontSize(int size) Specifies the font size which shall be applied to all noncomplex script characters in the content of this run when displayed. |
5 |
setText(java.lang.String value) Sets the text of this text run. |
6 |
setBold(boolean value) Specifies whether the bold property shall be applied to all non-complex script characters in the content of this run when displayed in a document. |
有关此类的其余方法,请参阅位于以下位置的完整API文档:
这是org.apache.poi.xwpf.usermodel包下的类,用于向Word文档中的对象元素添加不同的样式。
Sr.No. | Method & Description |
---|---|
1 |
getNextStyleID() It is used to get StyleID of the next style. |
2 |
getStyleId() It is used to get StyleID of the style. |
3 |
getStyles() It is used to get styles. |
4 |
setStyleId(java.lang.String styleId) It is used to set styleID. |
有关此类的其余方法,请参阅位于以下位置的完整API文档:
这是org.apache.poi.xwpf.usermodel包下的类,用于将表数据添加到word文档中。
Sr.No. | Method & Description |
---|---|
1 |
addNewCol() Adds a new column for each row in this table. |
2 |
addRow(XWPFTableRow row, int pos) Adds a new Row to the table at position pos. |
3 |
createRow() Creates a new XWPFTableRow object with as many cells as the number of columns defined in that moment. |
4 |
setWidth(int width) Sets the width of the column. |
有关此类的其余方法,请参阅以下位置的完整API文档: POI API文档
这是org.apache.poi.xwpf.extractor包下的类。它是一个基本的解析器类,用于从Word文档中提取简单文本。
Sr.No. | Method & Description |
---|---|
1 |
getText() Retrieves all the text from the document. |
有关此类的其余方法,请参阅以下位置的完整API文档: POI API文档