List of usage examples for org.apache.poi.xwpf.usermodel XWPFDocument getPosOfTable
public int getPosOfTable(XWPFTable t)
From source file:biz.webgate.dominoext.poi.component.kernel.DocumentProcessor.java
License:Apache License
public XWPFDocument processDocument(ITemplateSource itsCurrent, List<IDocumentBookmark> bookmarks, List<DocumentTable> tables, FacesContext context, UIDocument uiDocument) throws POIException { Logger logCurrent = LoggerFactory.getLogger(this.getClass().getCanonicalName()); InputStream is = itsCurrent.getFileStream(); XWPFDocument dxDocument = getDocument(is); itsCurrent.cleanUP();/* w w w. j a v a2 s.com*/ if (bookmarks != null && bookmarks.size() > 0) { processBookmarks2Document(dxDocument, bookmarks); } logCurrent.finest("Start export Tables"); if (tables != null && tables.size() > 0) { for (DocumentTable tblExport : tables) { XWPFTable dxTable = EmbeddedDataSourceExportProcessor.getInstance().processExportTable(tblExport, dxDocument, context, tblExport.getVar(), tblExport.getIndex()); logCurrent.finest("exportTable created"); // logCurrent.finer("Start Processing Cells"); if (tblExport.getDocCellValues() != null && tblExport.getDocCellValues().size() > 0) { for (ICellValue iCV : tblExport.getDocCellValues()) { if (iCV instanceof DocCellValue) { DocCellValue cv = (DocCellValue) iCV; if (cv.getRowNumber() <= tblExport.getMaxRow()) { DocumentProcessor.setDocCellValue(dxTable, cv.getRowNumber(), cv.getColumnNumber(), cv.getValue(), tblExport.getMaxRow(), false); } else { logCurrent.finer("MaxValue < CellValue.getRowNumber()"); } } } } if (dxTable != null) { logCurrent.finest("Set Table Position"); if (tblExport.getTableNr() != 0) { dxDocument.setTable(tblExport.getTableNr(), dxTable); dxDocument.removeBodyElement(dxDocument.getPosOfTable(dxTable)); } } /* * if (dxTable != null) { System.out.println("Insert Table"); * dxDocument.insertTable(2, dxTable); } */ // System.out.println(dxDocument.getPosOfParagraph(p)); // logCurrent.finer("Proccess Export Cells - DONE"); } } if (uiDocument != null) { uiDocument.postGenerationProcess(context, dxDocument); } return dxDocument; }