本文整理了Java中org.apache.poi.xwpf.usermodel.XWPFDocument.getTables()
方法的一些代码示例,展示了XWPFDocument.getTables()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFDocument.getTables()
方法的具体详情如下:
包路径:org.apache.poi.xwpf.usermodel.XWPFDocument
类名称:XWPFDocument
方法名:getTables
暂无
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* get a table by its CTTbl-Object
*
* @param ctTbl
* @return a table by its CTTbl-Object or null
* @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
*/
@Override
public XWPFTable getTable(CTTbl ctTbl) {
for (int i = 0; i < tables.size(); i++) {
if (getTables().get(i).getCTTbl() == ctTbl) {
return getTables().get(i);
}
}
return null;
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(OPCPackage.open("input.docx"));
for (XWPFParagraph p : doc.getParagraphs()) {
List<XWPFRun> runs = p.getRuns();
if (runs != null) {
for (XWPFRun r : runs) {
String text = r.getText(0);
if (text != null && text.contains("needle")) {
text = text.replace("needle", "haystack");
r.setText(text, 0);
}
}
}
}
for (XWPFTable tbl : doc.getTables()) {
for (XWPFTableRow row : tbl.getRows()) {
for (XWPFTableCell cell : row.getTableCells()) {
for (XWPFParagraph p : cell.getParagraphs()) {
for (XWPFRun r : p.getRuns()) {
String text = r.getText(0);
if (text.contains("needle")) {
text = text.replace("needle", "haystack");
r.setText(text);
}
}
}
}
}
}
doc.write(new FileOutputStream("output.docx"));
代码示例来源:origin: Sayi/poi-tl
@Override
public List<ElementTemplate> visitDocument(XWPFDocument doc) {
if (null == doc)
return null;
this.eleTemplates = new ArrayList<ElementTemplate>();
visitParagraphs(doc.getParagraphs());
visitTables(doc.getTables());
visitHeaders(doc.getHeaderList());
visitFooters(doc.getFooterList());
return eleTemplates;
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* get a table by its CTTbl-Object
* @param ctTbl
* @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
* @return a table by its CTTbl-Object or null
*/
public XWPFTable getTable(CTTbl ctTbl) {
for (int i = 0; i < tables.size(); i++) {
if (getTables().get(i).getCTTbl() == ctTbl) {
return getTables().get(i);
}
}
return null;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* get a table by its CTTbl-Object
*
* @param ctTbl
* @return a table by its CTTbl-Object or null
* @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
*/
@Override
public XWPFTable getTable(CTTbl ctTbl) {
for (int i = 0; i < tables.size(); i++) {
if (getTables().get(i).getCTTbl() == ctTbl) {
return getTables().get(i);
}
}
return null;
}
代码示例来源:origin: org.hswebframework/hsweb-expands-office
@Override
public void read(InputStream inputStream, WordReaderCallBack callBack) throws Exception {
XWPFDocument document = new XWPFDocument(inputStream);
document.getParagraphs().forEach(callBack::onParagraph);
document.getTables().forEach(callBack::onTable);
callBack.done(document);
}
代码示例来源:origin: hs-web/hsweb-expands
@Override
public void read(InputStream inputStream, WordReaderCallBack callBack) throws Exception {
XWPFDocument document = new XWPFDocument(inputStream);
document.getParagraphs().forEach(callBack::onParagraph);
document.getTables().forEach(callBack::onTable);
callBack.done(document);
}
代码示例来源:origin: stackoverflow.com
for (XWPFTable tbl : doc.getTables()) {
for (XWPFTableRow row : tbl.getRows()) {
for (XWPFTableCell cell : row.getTableCells()) {
代码示例来源:origin: micromata/projectforge
private void replaceInTable(XWPFDocument document, String searchText, String replacement)
{
for (XWPFTable tbl : document.getTables()) {
for (XWPFTableRow row : tbl.getRows()) {
for (XWPFTableCell cell : row.getTableCells()) {
for (XWPFParagraph paragraph : cell.getParagraphs()) {
replaceInParagraph(paragraph, searchText, replacement);
}
}
}
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(fis);
List<XWPFTable> tables = doc.getTables();
XWPFTable table = tables.get(0);
代码示例来源:origin: stackoverflow.com
System.out.println(paragraph.getParagraphText());
List<XWPFTable> tables = document.getTables();
for (int x=0; x<tables.size();x++) {
XWPFTable table = tables.get(x);
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(OPCPackage.open(sourse
+ "XXXXX_TestReport_URL_Document.doc"));
for (XWPFTable tbl : doc.getTables()) {
for (XWPFTableRow row : tbl.getRows()) {
for (XWPFTableCell cell : row.getTableCells()) {
代码示例来源:origin: stackoverflow.com
replaceInParagraphs(xwpfParagraphs);
List<XWPFTable> tables = template.getTables();
for (XWPFTable xwpfTable : tables) {
List<XWPFTableRow> tableRows = xwpfTable.getRows();
代码示例来源:origin: com.github.nic-luo/rober-office
/**
* 构造函数,用以分析文档,解析出所有的标签
*
* @param document Word OOXML document instance.
*/
public WordBookMarkParser(XWPFDocument document) {
//初始化标签缓存
this.bookmarks = new HashMap<String, BookMark>();
// 首先解析文档普通段落中的标签
this.procParaList(document.getParagraphs());
//利用繁琐的方法,从所有的表格中得到得到标签,处理比较原始和简单
List<XWPFTable> tableList = document.getTables();
for (XWPFTable table : tableList) {
//得到表格的列信息
List<XWPFTableRow> rowList = table.getRows();
for (XWPFTableRow row : rowList){
//得到行中的列信息
List<XWPFTableCell> cellList = row.getTableCells();
for (XWPFTableCell cell : cellList) {
//逐个解析标签信息
//this.procParaList(cell.getParagraphs(), row);
this.procParaList(cell);
}
}
}
}
代码示例来源:origin: micromata/projectforge
private XWPFTable generatePosTableRows(final XWPFDocument templateDocument, final List<RechnungsPositionDO> positionen)
{
XWPFTable posTbl = null;
for (XWPFTable tbl : templateDocument.getTables()) {
if (tbl.getRow(0).getCell(0).getText().contains("Beschreibung")) {
posTbl = tbl;
}
}
for (int i = 2; i <= positionen.size(); i++) {
copyTableRow(posTbl, i);
}
int rowCount = 1;
for (RechnungsPositionDO position : positionen) {
for (XWPFTableCell cell : posTbl.getRow(rowCount).getTableCells()) {
for (XWPFParagraph cellParagraph : cell.getParagraphs()) {
replaceInParagraph(cellParagraph, "id", String.valueOf(position.getNumber()));
}
}
rowCount++;
}
return posTbl;
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(new FileInputStream(fileName));
List<XWPFTable> table = doc.getTables();
for (XWPFTable xwpfTable : table) {
List<XWPFTableRow> row = xwpfTable.getRows();
for (XWPFTableRow xwpfTableRow : row) {
List<XWPFTableCell> cell = xwpfTableRow.getTableCells();
for (XWPFTableCell xwpfTableCell : cell) {
if (xwpfTableCell != null) {
System.out.println(xwpfTableCell.getText());
String s = xwpfTableCell.getText();
for (XWPFParagraph p : xwpfTableCell.getParagraphs()) {
for (XWPFRun run : p.getRuns()) {
for (XWPFPicture pic : run.getEmbeddedPictures()) {
byte[] pictureData = pic.getPictureData().getData();
System.out.println("picture : " + pictureData);
}
}
}
}
}
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(new FileInputStream(fileName));
List<XWPFTable> table = doc.getTables();
for (XWPFTable xwpfTable : table) {
List<XWPFTableRow> row = xwpfTable.getRows();
for (XWPFTableRow xwpfTableRow : row) {
List<XWPFTableCell> cell = xwpfTableRow.getTableCells();
for (XWPFTableCell xwpfTableCell : cell) {
if (xwpfTableCell != null) {
System.out.println(xwpfTableCell.getText());
String s = xwpfTableCell.getText();
for (XWPFParagraph p : xwpfTableCell.getParagraphs()) {
for (XWPFRun run : p.getRuns()) {
for (XWPFPicture pic : run.getEmbeddedPictures()) {
byte[] pictureData = pic.getPictureData().getData();
System.out.println("picture : " + pictureData);
}
}
}
}
}
}
}
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(fis);
List<XWPFTable> tables = doc.getTables();
XWPFTable table = tables.get(0);
代码示例来源:origin: stackoverflow.com
int pos = destDoc.getTables().size() - 1;
代码示例来源:origin: stackoverflow.com
XWPFDocument doc = new XWPFDocument(fis);
List<XWPFTable> tables = doc.getTables();
XWPFTable table = tables.get(0);
内容来源于网络,如有侵权,请联系作者删除!