InsertCellAt() public method

Inserts the cell at the given zero based position.
public InsertCellAt ( int position, Cell cell ) : void
position int The position.
cell Cell The cell.
return void
示例#1
0
        /// <summary>
        /// Inserts the cell at the specified position. Both indexes are 1-based indexes!
        /// The RowCollection, the rows CellCollection and the ColumnCollection
        /// will be resized automatically.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="cell">The cell.</param>
        public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
        {
            if (this.RowCollection.Count <= rowIndex)
            {
                for (int i = 0; i < rowIndex - this.RowCollection.Count; i++)
                {
                    this.RowCollection.Add(new Row(this, "row" + this.RowCollection.Count.ToString() + i.ToString()));
                }

                this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
                cell.Row = this.RowCollection[rowIndex - 1];
            }
            else if (this.RowCollection.Count + 1 == rowIndex)
            {
                Row row = new Row(this, this.RowCollection[this.RowCollection.Count - 1].StyleName);
                row.InsertCellAt(columnIndex - 1, cell);
                cell.Row = row;
                this.RowCollection.Add(row);
            }
            else
            {
                this.RowCollection[rowIndex - 1].InsertCellAt(columnIndex - 1, cell);
                cell.Row = this.RowCollection[rowIndex - 1];
            }
        }
示例#2
0
        /// <summary>
        /// Inserts the cell at the specified position.
        /// The RowCollection, the rows CellCollection and the ColumnCollection
        /// will be resized automatically.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="cell">The cell.</param>
        public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
        {
            while (_rows.Count <= rowIndex)
            {
                _rows.Add(new Row(this, String.Format("row{0}", _rows.Count)));
            }

            Row row = _rows [rowIndex];

            row.InsertCellAt(columnIndex, cell);
            cell.Row = row;
        }
示例#3
0
        /// <summary>
        /// Inserts the cell at the specified position. Both indexes are 1-based indexes!
        /// The RowCollection, the rows CellCollection and the ColumnCollection
        /// will be resized automatically.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="cell">The cell.</param>
        public void InsertCellAt(int rowIndex, int columnIndex, Cell cell)
        {
            if(this.RowCollection.Count <= rowIndex)
            {
                for(int i=0; i < rowIndex-this.RowCollection.Count; i++)
                    this.RowCollection.Add(new Row(this, "row"+this.RowCollection.Count.ToString()+i.ToString()));

                this.RowCollection[rowIndex-1].InsertCellAt(columnIndex-1, cell);
                cell.Row				= this.RowCollection[rowIndex-1];
            }
            else if(this.RowCollection.Count+1 == rowIndex)
            {
                Row row					= new Row(this, this.RowCollection[this.RowCollection.Count-1].StyleName);
                row.InsertCellAt(columnIndex-1, cell);
                cell.Row				= row;
                this.RowCollection.Add(row);
            }
            else
            {
                this.RowCollection[rowIndex-1].InsertCellAt(columnIndex-1, cell);
                cell.Row				= this.RowCollection[rowIndex-1];
            }
        }
		/// <summary>
		/// Creates the tables.
		/// </summary>
		/// <param name="lines">The lines.</param>
		private void CreateTables(ArrayList lines)
		{
			string unicodeDelimiter				= "\u00BF"; // turned question mark

			if (lines != null)
			{
				Table table						= TableBuilder.CreateSpreadsheetTable(
					(SpreadsheetDocument)this._document, "Table1", "table1");
				//First line must specify the used delimiter
				string delimiter				= lines[0] as string;
				lines.RemoveAt(0);

				try
				{
					//Perform lines
					foreach(string line in lines)
					{
						string lineContent			= line.Replace(delimiter, unicodeDelimiter);
						string[] cellContents		= lineContent.Split(unicodeDelimiter.ToCharArray());
						Row row						= new Row(table);
						foreach(string cellContent in cellContents)
						{
							Cell cell				= new Cell(table.Document);
							Paragraph paragraph		= ParagraphBuilder.CreateSpreadsheetParagraph(this._document);
							paragraph.TextContent.Add(new SimpleText(this._document, cellContent));
							cell.Content.Add(paragraph);
							row.InsertCellAt(row.Cells.Count, cell);
						}
						table.Rows.Add(row);
					}
				}
				catch(Exception ex)
				{
					throw new AODLException("Error while proccessing the csv file.", ex);
				}

				this._document.Content.Add(table);
			}
		}