@ankit goel , Welcome to Microsoft Q&A,
The error you get means that you could not convert 1 PCS to int type.
We need to remove the PCS first and then convert string 1 to int 1.
Here is a code example you could refer to.
var arr = (object[,])range1.get_Value(XlRangeValueDataType.xlRangeValueDefault);
for (int i = 1; i <= arr.GetLength(0); i++)
{
if (arr[i, 1] != null)
{
int id = Convert.ToInt32(arr[i, 2].ToString().Replace("PCS", "").Trim());
if(id>30)
{
listnew.Add(new object[] { arr[i, 1] });
}
}
}
Result:
Hope my code could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.