[Solved] Using C#, how do I get all rows from smartsheet where “x” is in column 2?


Below is the code I managed to find after a little more searching:

 public void GetJobNoOfAllProjects(SmartsheetClient smartsheet, long sheetId, out List<string> matches)
{
    jobNoMatches = new List<string>();
    Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
            
    foreach (Row tmpRow in sheet.Rows)
    {
        if (tmpRow.Cells[2].Value.ToString() == "PROJECT")
        {
            //Do what is required to the row
            jobNoMatches.Add(tmpRow.Cells[0].Value.ToString());
        }
    }
}

Needs error handling in case it comes across a blank cell, but that’s what I came up with.

ALTERNATIVELY

 public void GetJobNoOfAllProjects(SmartsheetClient smartsheet, long sheetId, out List<string> matches)
{
    jobNoMatches = new List<string>();
    Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);

    int loop = 0;
    while (loop < sheet.Rows.Count)
    {
        if (sheet.Rows[loop].Cells[2].Value.ToString() == "PROJECT")
        {
            //Do what is required to the row
            jobNoMatches.Add(sheet.Rows[loop].Cells[0].Value.ToString());
        }
        loop++;
    }
}

solved Using C#, how do I get all rows from smartsheet where “x” is in column 2?