Reading Cell Values in Multiple Threads Simultaneously
Contents
[
Hide
]
Needing to read cell values in multiple threads simultaneously is a common requirement. This article explains how to use Aspose.Cells for this purpose.
To read cell values in more than one thread simultaneously, set Worksheet.Cells.MultiThreadReading to true. If you do not, you might get the wrong cell values.
The following code:
- Creates a workbook.
- Adds a worksheet.
- Populates the worksheet with string values.
- It then creates two threads that simultaneously read values from random cells. If the values read are correct, nothing happens. If the values read are incorrect, then a message is displayed.
If you comment this line:
testWorkbook.Worksheets[0].Cells.MultiThreadReading = true;
then the following message is displayed:
if (s != "R" + row + "C" + col)
{
MessageBox.Show("This message box will show up when cells read values are incorrect.");
}
Otherwise, the program runs without showing any message which means all values read from cells are correct.