AODL.Document.Content.Charts.Chart.GetCellPos C# (CSharp) Метод

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

gets the rowIndex and colIndex of the chart according to the name of the cell
public GetCellPos ( string cellName, Table tableData ) : CellPos
cellName string
tableData AODL.Document.Content.Tables.Table
Результат CellPos
		public CellPos  GetCellPos(string cellName,Table tableData)
		{
			int  i = 0;
			int  columnIndex = 0;
			int  rowIndex    = 0;
			char[] columnStr = new char [2];
			string rowStr    = null;
			
			foreach(char c in cellName)
			{
				if (c>='A'&&c<='Z')
				{
					columnStr[i]=c;
					i++;
				}
			}

			if (i==1)
				columnIndex = columnStr[0]-'A';
			if (i==2)
				columnIndex=(columnStr[0]-'A')*26 +(columnStr[1]-'A');
			columnIndex    = columnIndex+1;

			rowStr    = cellName.Substring (i);
			rowIndex  = Int32.Parse (rowStr);

			Cell cell = null;

			if (rowIndex<=tableData.Rows .Count )
			{
				Row row = tableData.Rows [rowIndex-1];
				if (columnIndex<=row.Cells.Count )
				{
					cell= tableData.Rows [rowIndex-1].Cells [columnIndex-1];
				}
			}

			if (cell==null)
			{
				cell = new Cell(_document);
				tableData.InsertCellAt (rowIndex,columnIndex,cell);
			}

			CellPos    pos = new CellPos ();

			pos.cell =cell;
			pos.columnIndex = columnIndex;
			pos.rowIndex    = rowIndex;
			return pos;
		}

Usage Example

Пример #1
0
		public void InsertChartAt(string cellName,Chart chart)
		{
			string endCell= chart.EndCellAddress ;
			
			if (endCell==null)
			{
				int CurRowIndex= chart.GetCellPos (cellName,this).rowIndex ;
				int CurColIndex= chart.GetCellPos (cellName,this).columnIndex ;
				int EndRowIndex = CurRowIndex +15;
				int EndColIndex = CurColIndex +5;

				string EndCellRow  =EndRowIndex.ToString ();
				string EndCellCol  = null;

				if (EndColIndex<=26)
				{
					char  col = (char)(EndColIndex+'A'-1);
					EndCellCol=col.ToString ();
				}

				else if (CurColIndex>26&&CurColIndex<=260)
				{
					int FirstCha = CurColIndex/26;
					char FirstCharacter = (char)(FirstCha+'A'-1);
					int SecondCha =CurColIndex%2 ;
					char SecondChatacter = (char)(SecondCha+'A'-1);
					EndCellCol=FirstCharacter.ToString ()+SecondChatacter.ToString ();
				}

				endCell = this.TableName +"."+EndCellCol+EndCellRow;
				chart.EndCellAddress =endCell;
			}

			Cell   cell = (chart.GetCellPos (cellName,this)).cell ;
			cell.Content .Add (chart.Frame );
		}