title: MFC How do I get the excel 2007 driver, to prevent the limit of 65536 rows
body: <p>Use MFC to insert data to excel 2003, I found the limit of 65536 rows, </p>
  
  <p>I don't want to create another sheet to save data, so I want use excel 2007,</p>
  
  <p>which extension is .xlsx. </p>
  
  <p>I use follow code to get driver </p>
  
  <pre><code>((CDR12Dlg*)AfxGetMainWnd())-&gt;sExcelDriver = _T("MICROSOFT EXCEL DRIVER (*.xls)");
  
  ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelFilePath.Format(((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strBaseFolder);
      ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelFilePath.AppendFormat(_T("%s_%s_%.0f℃_%d%s"),
                                                                                  ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strDevID,
                                                                                  ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strDevModel,
                                                                                  theApp.fTab1TestAvgTemp,
                                                                                  loop,
                                                                                  _T(".xls"));
  
  TRY
  {
      // Build the creation string for access without DSN
      strSql.Format(_T("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=/%s/;DBQ=%s"),
          ((CDR12Dlg*)AfxGetMainWnd())-&gt;sExcelDriver, 
          ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelFilePath, 
          ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelFilePath);
  
          // Create the database (i.e. Excel sheet)
          if( ((CDR12Dlg*)AfxGetMainWnd())-&gt;database.OpenEx(strSql,CDatabase::noOdbcDialog) )
          {
              ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelTableName.Empty();
              ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelTableName.Format(_T("%s_%s"), 
                                                          ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strDevID, 
                                                          ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strDevModel);
  
              CString strSqlField;
              strSqlField.Format(_T("RecvTime TEXT,"));
              for(int loop=1; loop&lt;=theApp.nTab1TestPointNumber; loop++)
              {
                  if(loop == theApp.nTab1TestPointNumber)
                  {
                      strSqlField.AppendFormat(_T("TestPoint%d NUMBER"), loop);
                  } else {
                      strSqlField.AppendFormat(_T("TestPoint%d NUMBER,"), loop);
                  }
              }
              // Create table structure
              strSql.Format(_T("CREATE TABLE \"%s\" (%s)"), 
                  ((CDR12Dlg*)AfxGetMainWnd())-&gt;sTab1CurveFile.strExcelTableName,
                  strSqlField);
  
              ((CDR12Dlg*)AfxGetMainWnd())-&gt;database.ExecuteSQL(strSql);
  
              }     
  
              // Close database
              ((CDR12Dlg*)AfxGetMainWnd())-&gt;database.Close();
          }
          CATCH_ALL(e)
          {
              TRACE1("Driver not installed: %s\n",((CDR12Dlg*)AfxGetMainWnd())-&gt;sExcelDriver);
          }
          END_CATCH_ALL;
  </code></pre>
  
  <p>Ok, above code is work well in Excel 2003, but I change the code from .</p>
  
  <pre><code>sExcelDriver = _T("MICROSOFT EXCEL DRIVER (*.xls)");
  </code></pre>
  
  <p>replace  </p>
  
  <pre><code>sExcelDriver = _T("MICROSOFT EXCEL DRIVER (*.xlsx)");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sExcelDriver = _T("MICROSOFT EXCEL DRIVER (*.xls, xlsx)");
  </code></pre>
  
  <p>and save as .xlsx file</p>
  
  <p>but the result will show me "Driver not installed"</p>
  
  <p>I have try to install the AccessDatabaseEngine, which link the excel 2007, </p>
  
  <p>how do I change the code to acces excel 2007 file.</p>