title: Using Microsoft Excel via an ODBC Driver with PHP
body: <p>I am trying to insert data and select data from Excel using an ODBC connection. I have managed to connect to it:</p>
  
  <pre><code>$dbh = new PDO("odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Dbq=$file_name", $username, $password);
  </code></pre>
  
  <p>However, I am unsure how to query Excel as there is minimal documentation for this! I attempted this:</p>
  
  <pre><code>$query = "INSERT INTO $sheet ($cell) VALUES ($value)";
  
  $result = $dbh-&gt;query($query);
  </code></pre>
  
  <p>But this leads to an error:</p>
  
  <blockquote>
    <p>Array ( [0] => 07002 [1] => -3010 [2]
    => [Microsoft][ODBC Excel Driver] The Microsoft Office Access database
    engine could not find the object
    'Sheet1'. Make sure the object exists and
    that you spell its name and the path
    name correctly. (SQLExecute[-3010] at
    ext\pdo_odbc\odbc_stmt.c:254) [3] =>
    07002 )</p>
  </blockquote>
  
  <p>By object, hopefully they mean an excel sheet?</p>
  
  <p>Thanks all for any help</p>