title: Read a single cell from Excel to a string using C# and ASP.NET
body: <p>I need to read a single cell from an xsl excel file to a string withing the web application i am building. I was previously pulling cell ranges from the file to a table using the following code:</p>
  
  <pre><code>string PullFromExcell(string CellNo)
      {
          string cell;
          string properties = String.Format(@"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\User\Desktop\file.xls; Extended Properties = 'Excel 8.0;'");
  
          using (OleDbConnection conn = new OleDbConnection(properties))
          {
              string worksheet = "Sheet";
              conn.Open();
              DataSet ds = new DataSet();
              using (OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [" + worksheet + "$" + CellNo + "]", properties))
              {
  
                  DataTable dt = new DataTable();
                  cell = dt.ToString(); 
                  da.Fill(dt);
                  ds.Tables.Add(dt);
  
                  grdComponent.DataSource = dt;
                  grdComponent.DataBind();
              }
          }
  
         return cell;
      }
  </code></pre>
  
  <p>How would i send that to a string? The code that i would use when pulling from a database is similar to this:</p>
  
  <pre><code>Sqlstring = "Select data from variable where name = 'fred' and ssn = 1234";
  var cmd0 = new SqlCommand(Sqlstring, Class_Connection.cnn);
  string Data = cmd0.ExecuteScalar().ToString();
  </code></pre>
  
  <p>i'm just not sure if any of that is compatible. </p>