GetCell() публичный Метод

Gets a Cell or Table from a certain column.
public GetCell ( int column ) : Object
column int the column the Cell/Table is in.
Результат Object
Пример #1
0
 /**
 * Imports a Row and copies all settings
 * 
 * @param row The Row to import
 */
 private void ImportRow(Row row) {
     this.cells = new ArrayList();
     this.width = this.document.GetDocumentHeader().GetPageSetting().GetPageWidth() - this.document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - this.document.GetDocumentHeader().GetPageSetting().GetMarginRight();
     this.width = (int) (this.width * this.parentTable.GetTableWidthPercent() / 100);
     
     int cellRight = 0;
     int cellWidth = 0;
     for (int i = 0; i < row.Columns; i++) {
         cellWidth = (int) (this.width * this.parentTable.GetProportionalWidths()[i] / 100);
         cellRight = cellRight + cellWidth;
         
         Cell cell = (Cell) row.GetCell(i);
         RtfCell rtfCell = new RtfCell(this.document, this, cell);
         rtfCell.SetCellRight(cellRight);
         rtfCell.SetCellWidth(cellWidth);
         this.cells.Add(rtfCell);
     }
 }
Пример #2
0
        /**
        * Import a <code>Row</code>.
        * <P>
        * All the parameters are taken from the <code>RtfTable</code> which contains
        * this <code>RtfRow</code> and they do exactely what they say
        * @param row
        * @param propWidths in percent
        * @param tableWidth in percent
        * @param pageWidth
        * @param cellpadding
        * @param cellspacing
        * @param borders
        * @param borderColor
        * @param borderWidth
        * @param y
        * @return true if importing the row succeeded
        */
        public bool ImportRow(Row row, float[] propWidths, int tableWidth, int pageWidth, int cellpadding,
                                int cellspacing, int borders, Color borderColor, float borderWidth,
                                int y)
        {
            // the width of this row is the absolute witdh, calculated from the
            // proportional with of the table and the total width of the page
            this.origRow = row;
            this.width = pageWidth * tableWidth / 100;
            this.cellpadding = cellpadding;
            this.cellspacing = cellspacing;
            this.borders = borders;
            this.borderColor = borderColor;
            this.borderWidth = borderWidth;

            if (this.borderWidth > 2) this.borderWidth = 2;

            int cellLeft = 0;
            for (int i = 0; i < row.Columns; i++) {
                IElement cell = (IElement) row.GetCell(i);

                // cellWidth is an absolute argument
                // it's based on the absolute of this row and the proportional
                // width of this column
                int cellWidth = (int) (width * propWidths[i] / 100);
                if (cell != null) {
                    if (cell.Type == Element.CELL) {
                        RtfCell rtfCell = (RtfCell) cells[i];
                        cellLeft = rtfCell.ImportCell((Cell) cell, cellLeft, cellWidth, i, y, cellpadding);
                    }
                } else {
                    RtfCell rtfCell = (RtfCell) cells[i];
                    cellLeft = rtfCell.ImportCell(null, cellLeft, cellWidth, i, y, cellpadding);
                }
            }

            // recalculate the cell right border and the cumulative width
            // on col spanning cells.
            // col + row spanning cells are also handled by this loop, because the real cell of
            // the upper left corner in such an col, row matrix is copied as first cell
            // in each row in this matrix
            int columns = row.Columns;
            for (int i = 0; i < columns; i++) {
                RtfCell firstCell = (RtfCell) cells[i];
                Cell cell = firstCell.GetStore();
                int cols = 0;
                if (cell != null) {
                    cols = cell.Colspan;
                }
                if (cols > 1) {
                    RtfCell lastCell = (RtfCell) cells[i + cols - 1];
                    firstCell.SetCellRight(lastCell.GetCellRight());
                    int width = firstCell.GetCellWidth();
                    for (int j = i + 1; j < i + cols; j++) {
                        RtfCell cCell = (RtfCell) cells[j];
                        width += cCell.GetCellWidth();
                    }
                    firstCell.SetCellWidth(width);
                    i += cols - 1;
                }
            }
            return true;
        }