Reputation: 29
i am not a pro in C#, I'm still learning and i just wanted a loop that checks if the cell is empty then write in it by a windows form for example
while (true)
{
object i = 2;
if (xlWorkSheet.Cells[i, 1].Value2 == null)
{
xlWorkSheet.Cells[i, 1].Value2 = textBox2.Text;
break;
}
else
i++;
}
i can't increment an object and to select a cell i have to use this data type So is there any replace for this loop
Upvotes: 0
Views: 164
Reputation: 350
try this
int count = 2;
while (true)
{
object i = count;
if (xlWorkSheet.Cells[i, 1].Value2 == null)
{
xlWorkSheet.Cells[i, 1].Value2 = textBox2.Text;
break;
}
else
count++;
}
Upvotes: 1