Exemplo n.º 1
0
Arquivo: Range.cs Projeto: zzy092/npoi
        /**
         * Inserts a simple table into the beginning of this range.
         *
         * @param columns
         *            The number of columns
         * @param rows
         *            The number of rows.
         * @return The empty Table that is now part of the document.
         */
        public Table InsertTableBefore(short columns, int rows)
        {
            ParagraphProperties parProps = new ParagraphProperties();

            parProps.SetFInTable(true);
            parProps.SetItap(1);

            int oldEnd = this._end;

            for (int x = 0; x < rows; x++)
            {
                Paragraph cell = this.InsertBefore(parProps, StyleSheet.NIL_STYLE);
                cell.InsertAfter(Convert.ToString('\u0007'));
                for (int y = 1; y < columns; y++)
                {
                    cell = cell.InsertAfter(parProps, StyleSheet.NIL_STYLE);
                    cell.InsertAfter(Convert.ToString('\u0007'));
                }
                cell = cell.InsertAfter(parProps, StyleSheet.NIL_STYLE,
                                        Convert.ToString('\u0007'));
                cell.SetTableRowEnd(new TableProperties(columns));
            }

            int newEnd = this._end;
            int diff   = newEnd - oldEnd;

            return(new Table(_start, _start + diff, this, 1));
        }
Exemplo n.º 2
0
Arquivo: Range.cs Projeto: zzy092/npoi
        public Table InsertBefore(TableProperties props, int rows)
        {
            ParagraphProperties parProps = new ParagraphProperties();

            parProps.SetFInTable(true);
            parProps.SetItap(1);

            int columns = props.GetItcMac();

            for (int x = 0; x < rows; x++)
            {
                Paragraph cell = this.InsertBefore(parProps, StyleSheet.NIL_STYLE);
                cell.InsertAfter("\u0007");
                for (int y = 1; y < columns; y++)
                {
                    cell = cell.InsertAfter(parProps, StyleSheet.NIL_STYLE);
                    cell.InsertAfter("\u0007");
                }
                cell = cell.InsertAfter(parProps, StyleSheet.NIL_STYLE, "\u0007");
                cell.SetTableRowEnd(props);
            }
            return(new Table(_start, _start + (rows * (columns + 1)), this, 1));
        }