Note: I have solved this problem using a brute force double for loop. I need a faster and more efficient way of solving it in C# specifically.
Consider the Word table below.
I need an efficient method of finding a given column and a given row and placing text in the intersecting cell. For example lets say I'm given 1 as my column and A as my row. Then the text would go into the cell with the index row:2,col:2.
Things I have tried:
Iterating over all the rows and columns. This is slow and takes a significant amount of time.
To speed it up I attempted to use Range.Find but struggled to know where the found cell was in the context of the table. Here is some rough code of what I was thinking. I am well aware this is missing checks if the items arent found or if there are multiple but I can deal with that later.
int col;
int row;
var searchRange = table.Range;
var isFound = searchRange.Find.Execute(FindText:rowText);
if(isFound){
searchRange.Select();
col = searchRange.SOME_FUNCTION_THAT_WILL_REVEAL_THE_CELLS_COL_INDEX_WITHIN_THE_TABLE();
}
var searchRange = table.Range;
var isFound = searchRange.Find.Execute(FindText:rowText);
if(isFound){
searchRange.Select();
row = searchRange.SOME_FUNCTION_THAT_WILL_REVEAL_THE_CELLS_ROW_INDEX_WITHIN_THE_TABLE();
}
table.Cell(row, col).Text = "Some text For Desired Location";
