Migrant range for reading a value
Hi,
The documentation shows how to sufficiently set values on many rows using migrant range, but I also need to read a cell (to see if a comma exists or not) but I cannot find anywhere where it says how to get an existing cell value. Any help is appreciated.
Thanks.
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
SK
Shamini Kiruba Sobers
Syncfusion Team
October 26, 2020 09:48 AM UTC
Hi Travis,
Greetings from Syncfusion support.
You can read the cell content in a similar way with the same properties (Text or Value) which are used to get and set the values in a cell or range. Kindly refer the following UG links.
Kindly look into the following code snippet to achieve your requirement and let us know if it helps.
Code snippet:
|
IMigrantRange migrantRange = sheet.MigrantRange;
for (int row = 1; row <= migrantRange.LastRow; row++)
{
for (int column = 1; column <= migrantRange.LastColumn; column++)
{
//Read the cell text and check if it contains comma
migrantRange.ResetRowColumn(row, column);
var cellText = migrantRange.Text;
bool containsComma = cellText.Contains(",");
}
} |
Regards,
Shamini
Marked as answer
TC
Travis Chambers
October 27, 2020 05:54 PM UTC
Thank you for your response! This does work, but doesnt seem to speed up my process any. After discovering whether or not a comma exists in each value of a row, I then set formulas in 15 different columns.
Using MigrantRange I am simply using a row loop that looks something like this:
for(int i = 2; i <= lastrow; i++)
{
migrantRange.ResetRowColumn(row, 2);
migrantRange.Formula = "'Sheet1'!AE"+row+"";
}
Previously I was using IRange to set each row in the range to the formula like this:
application.EnableIncrementalFormula = true;
sheet.Range["B2:B"+lastrow+"].Formula = "'Sheet1'!AE2";
These two methods seem to be equally slow.
Thanks.
SK
Shamini Kiruba Sobers
Syncfusion Team
October 28, 2020 02:48 PM UTC
Hi Travis,
Thanks for the update.
While setting formulas, the performance will be similar in both cases. We need to know the type of formulas used along with the total number of rows and columns for further analysis. Kindly share us the issue reproducing sample or the input file used at your end, so that we can investigate further and provide prompt solution at the earliest.
Regards,
Shamini
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
TC Travis Chambers
- Oct 23, 2020 08:48 PM UTC
- Oct 28, 2020 02:48 PM UTC