@Override public XSLFTable createTable(int numRows, int numCols){ if (numRows < 1 || numCols < 1) { throw new IllegalArgumentException("numRows and numCols must be greater than 0"); } XSLFTable sh = getDrawing().createTable(); _shapes.add(sh); sh.setParent(this); for (int r=0; r<numRows; r++) { XSLFTableRow row = sh.addRow(); for (int c=0; c<numCols; c++) { row.addCell(); } } return sh; }
public XSLFTableCell addCell(){ CTTableCell c = _row.addNewTc(); c.set(XSLFTableCell.prototype()); XSLFTableCell cell = new XSLFTableCell(c, _table); _cells.add(cell); if(_table.getNumberOfColumns() < _row.sizeOfTcArray()) { _table.getCTTable().getTblGrid().addNewGridCol().setW(Units.toEMU(100.0)); } _table.updateRowColIndexes(); return cell; }
/* package */ void updateCellAnchor() { int rows = getNumberOfRows(); int cols = getNumberOfColumns(); rowHeights[row] = getRowHeight(row); colWidths[col] = getColumnWidth(col); Rectangle2D tblAnc = getAnchor(); DrawFactory df = DrawFactory.getInstance(null); double maxHeight = 0; for (int col=0; col<cols; col++) { XSLFTableCell tc = getCell(row, col); if (tc == null || tc.getGridSpan() != 1 || tc.getRowSpan() != 1) { continue; for (int col=0; col<cols; col++) { Rectangle2D bounds = new Rectangle2D.Double(newX, newY, colWidths[col], rowHeights[row]); XSLFTableCell tc = getCell(row, col); if (tc != null) { tc.setAnchor(bounds); XSLFTableCell tc = getCell(row, col); if (tc == null) { continue; for (int col2=col+1; col2<col+tc.getGridSpan(); col2++) { assert(col2 < cols); XSLFTableCell tc2 = getCell(row, col2);
CTTable ct = table.getCTTable(); if (!ct.isSetTblPr()) { return null; } else if (row == 0 && firstRow) { tps = TablePartStyle.firstRow; } else if (row == table.getNumberOfRows() - 1 && lastRow) { tps = TablePartStyle.lastRow; } else if (col == 0 && firstCol) { tps = TablePartStyle.firstCol; } else if (col == table.getNumberOfColumns() - 1 && lastCol) { tps = TablePartStyle.lastCol; } else { XSLFTableStyle tabStyle = table.getTableStyle(); if (tabStyle == null) { return null;
tbl.setAnchor(new Rectangle(50, 50, 450, 300)); XSLFTableRow headerRow = tbl.addRow(); headerRow.setHeight(50); th.setBorderColor(BorderEdge.bottom, Color.white); tbl.setColumnWidth(i, 150); // all columns are equally sized XSLFTableRow tr = tbl.addRow(); tr.setHeight(50);
public XSLFTableCell addCell(){ CTTableCell c = _row.addNewTc(); c.set(XSLFTableCell.prototype()); XSLFTableCell cell = new XSLFTableCell(c, _table.getSheet()); _cells.add(cell); if(_table.getNumberOfColumns() < _row.sizeOfTcArray()) { _table.getCTTable().getTblGrid().addNewGridCol().setW(Units.toEMU(100.0)); } return cell; }
/** * Get assigned TableStyle * * @return the assigned TableStyle * * @since POI 3.15-beta2 */ protected XSLFTableStyle getTableStyle() { CTTable tab = getCTTable(); // TODO: support inline table style if (!tab.isSetTblPr() || !tab.getTblPr().isSetTableStyleId()) { return null; } String styleId = tab.getTblPr().getTableStyleId(); XSLFTableStyles styles = getSheet().getSlideShow().getTableStyles(); for (XSLFTableStyle style : styles.getStyles()) { if (style.getStyleId().equals(styleId)) { return style; } } return null; }
for(XSLFShape shape : slide){ shape.getAnchor(); if (shape instanceof XSLFTable){ XSLFTable t = (XSLFTable) shape; if(t.getShapeName().equals("Table1")){ t.getCell(1,1).clearText(); t.getCell(1,1).addNewTextParagraph().addNewTextRun().setText("TABELE 1"); } } }
/* package */ XSLFTableCell(CTTableCell cell, XSLFTable table) { super(cell, table.getSheet()); this.table = table; }
static XSLFGraphicFrame create(CTGraphicalObjectFrame shape, XSLFSheet sheet){ final String uri = getUri(shape); switch (uri == null ? "" : uri) { case XSLFTable.TABLE_URI: return new XSLFTable(shape, sheet); case XSLFObjectShape.OLE_URI: return new XSLFObjectShape(shape, sheet); default: return new XSLFGraphicFrame(shape, sheet); } }
@Override public XSLFTableCell getCell(int row, int col) { List<XSLFTableRow> rows = getRows(); if (row < 0 || rows.size() <= row) { return null; } XSLFTableRow r = rows.get(row); if (r == null) { // empty row return null; } List<XSLFTableCell> cells = r.getCells(); if (col < 0 || cells.size() <= col) { return null; } // cell can be potentially empty ... return cells.get(col); }
/* package */ void updateCellAnchor() { int rows = getNumberOfRows(); int cols = getNumberOfColumns(); rowHeights[row] = getRowHeight(row); colWidths[col] = getColumnWidth(col); Rectangle2D tblAnc = getAnchor(); DrawFactory df = DrawFactory.getInstance(null); double maxHeight = 0; for (int col=0; col<cols; col++) { XSLFTableCell tc = getCell(row, col); if (tc == null || tc.getGridSpan() != 1 || tc.getRowSpan() != 1) { continue; for (int col=0; col<cols; col++) { Rectangle2D bounds = new Rectangle2D.Double(newX, newY, colWidths[col], rowHeights[row]); XSLFTableCell tc = getCell(row, col); if (tc != null) { tc.setAnchor(bounds); XSLFTableCell tc = getCell(row, col); if (tc == null) { continue; for (int col2=col+1; col2<col+tc.getGridSpan(); col2++) { assert(col2 < cols); XSLFTableCell tc2 = getCell(row, col2);
CTTable ct = table.getCTTable(); if (!ct.isSetTblPr()) { return null; } else if (row == 0 && firstRow) { tps = TablePartStyle.firstRow; } else if (row == table.getNumberOfRows() - 1 && lastRow) { tps = TablePartStyle.lastRow; } else if (col == 0 && firstCol) { tps = TablePartStyle.firstCol; } else if (col == table.getNumberOfColumns() - 1 && lastCol) { tps = TablePartStyle.lastCol; } else { XSLFTableStyle tabStyle = table.getTableStyle(); if (tabStyle == null) { return null;
/** * Get assigned TableStyle * * @return the assigned TableStyle * * @since POI 3.15-beta2 */ protected XSLFTableStyle getTableStyle() { CTTable tab = getCTTable(); // TODO: support inline table style if (!tab.isSetTblPr() || !tab.getTblPr().isSetTableStyleId()) { return null; } String styleId = tab.getTblPr().getTableStyleId(); XSLFTableStyles styles = getSheet().getSlideShow().getTableStyles(); for (XSLFTableStyle style : styles.getStyles()) { if (style.getStyleId().equals(styleId)) { return style; } } return null; }
/* package */ XSLFTableCell(CTTableCell cell, XSLFTable table) { super(cell, table.getSheet()); this.table = table; }
static XSLFGraphicFrame create(CTGraphicalObjectFrame shape, XSLFSheet sheet){ String uri = shape.getGraphic().getGraphicData().getUri(); if(XSLFTable.TABLE_URI.equals(uri)){ return new XSLFTable(shape, sheet); } else { return new XSLFGraphicFrame(shape, sheet); } }
XSLFTable t = null; for (XSLFShape shape : slide) { if (shape instanceof XSLFTable) { t = (XSLFTable) shape; r = t.getRows(); } }