use of org.apache.poi.xwpf.usermodel.XWPFSDTCell in project tika by apache.
the class XWPFWordExtractorDecorator method extractTable.
private void extractTable(XWPFTable table, XWPFListManager listManager, XHTMLContentHandler xhtml) throws SAXException, XmlException, IOException {
xhtml.startElement("table");
xhtml.startElement("tbody");
for (XWPFTableRow row : table.getRows()) {
xhtml.startElement("tr");
for (ICell cell : row.getTableICells()) {
xhtml.startElement("td");
if (cell instanceof XWPFTableCell) {
extractIBodyText((XWPFTableCell) cell, listManager, xhtml);
} else if (cell instanceof XWPFSDTCell) {
xhtml.characters(((XWPFSDTCell) cell).getContent().getText());
}
xhtml.endElement("td");
}
xhtml.endElement("tr");
}
xhtml.endElement("tbody");
xhtml.endElement("table");
}
use of org.apache.poi.xwpf.usermodel.XWPFSDTCell in project poi by apache.
the class XWPFWordExtractor method appendTableText.
private void appendTableText(StringBuffer text, XWPFTable table) {
//this works recursively to pull embedded tables from tables
for (XWPFTableRow row : table.getRows()) {
List<ICell> cells = row.getTableICells();
for (int i = 0; i < cells.size(); i++) {
ICell cell = cells.get(i);
if (cell instanceof XWPFTableCell) {
text.append(((XWPFTableCell) cell).getTextRecursively());
} else if (cell instanceof XWPFSDTCell) {
text.append(((XWPFSDTCell) cell).getContent().getText());
}
if (i < cells.size() - 1) {
text.append("\t");
}
}
text.append('\n');
}
}
Aggregations