Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 640299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:56:17+00:00 2026-05-13T20:56:17+00:00

I am trying to connect to excel table from Delphi 7 using TAdoConnection component.

  • 0

I am trying to connect to excel table from Delphi 7 using TAdoConnection component.
The problem is when I select Microsoft.Jet.OLEDB.4.0, Extended Properties=”Excel 8.0;”, I sometimes receive error,

that external table is not in the
expected format.

When i select:
Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;
then some users receive following error:

“Provider cannot be found. It may not
be properly installed”.

Is there a way to solve my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:56:18+00:00Added an answer on May 13, 2026 at 8:56 pm

    It’s been too long since I researched this to remember the details, but here is a sample of what we are doing with Excel. Hope this helps…

    type
      TConvertExcel = class(TAgCustomPlugin)
        ADOConnection1: TADOConnection;
        procedure FormCreate(Sender: TObject);
      private
        FSheetName: string;
        FExcelVersion: Currency;
    
        procedure ConnectToExcel;
        function ExcelSupported: Boolean;
        function GetExcelVersion: Currency;
      end;
    
    var
      ConvertExcel: TConvertExcel;
    
    implementation
    
    uses ...
    
    {$R *.dfm}
    
    {
      TConvertExcel.FormCreate
      ---------------------------------------------------------------------------
    }
    procedure TConvertExcel.FormCreate(Sender: TObject);
    begin
      FExcelVersion := GetExcelVersion;
    
      if ExcelSupported = False then
      begin
        grpConvertExcel.Visible := False;
        if FExcelVersion = 0 then
          lblNoExcel.Caption := 'Microsoft Excel Not Installed!'
        else
          lblNoExcel.Caption := 'Microsoft Excel Version Not Supported!';
        lblNoExcel.Caption := lblNoExcel.Caption + AsciiCRLF + AsciiCRLF +
          'Microsoft Excel 2003 or 2007 must be installed before an excel file can be converted.';
        lblNoExcel.Visible := True;
        exit;
      end;
    
    end;
    
    {
      TConvertExcel.GetExcelVersion
      ---------------------------------------------------------------------------
    }
    function TConvertExcel.GetExcelVersion: Currency;
    var
      ClassID: TCLSID;
      strOLEObject: string;
      Excel: OleVariant;
    begin
    
      result := 0;
    
      strOLEObject := 'Excel.Application';
    
      if (CLSIDFromProgID(PWideChar(WideString(strOLEObject)), ClassID) = S_OK) then
      begin
        Excel := CreateOleObject(strOLEObject);
        // qqqxxx - Should we be casting this differently?
        result := Excel.Version;
      end;
    
    end;
    
    {
      TConvertExcel.ExcelSupported
      ---------------------------------------------------------------------------
    }
    function TConvertExcel.ExcelSupported: Boolean;
    begin
      result := False;
      if (FExcelVersion = 11.0) or    // Excel 2003
         (FExcelVersion = 12.0) then  // Excel 2007
        result := True;
    end;
    
    {
      TExcelConverterPreview.ConnectToExcel
      ---------------------------------------------------------------------------
    }
    procedure TConvertExcel.ConnectToExcel;
    var
      strConn: widestring;
      SheetNameList: TStringList;
    begin
    
    /*
    when connecting to Excel "database",
    extended properties are used to set the Excel file version.
    For an Excel95 workbook this value is "Excel 5.0" (without the quotes),
    for versions Excel 97, Excel 2000, Excel 2002 or ExcelXP the value is "Excel 8.0".
    
    IMEX=1;" tells the driver to always read the registry at
    Hkey_Local_Machine/Software/Microsoft/Jet/4.0/Engines/Excel/ImportMixedTypes.
    If ImportMixedTypes=Text then intermixed types will always be cast to Text.
    If ImportMixedTypes=Majority Type then intermixed types will result in Null values.
    Luckily Text seems to be the default.
    */
    
      SheetNameList := nil;
    
      if FExcelVersion = 11.0 then
        strConn :='Provider=Microsoft.Jet.OLEDB.4.0;' +
          'Data Source="' + txtInputFile.Text + '";' +
          'Extended Properties="Excel 8.0;HDR=No;IMEX=1"'
      else if FExcelVersion = 12.0 then
        strConn := 'Provider=Microsoft.ACE.OLEDB.12.0;' +
          'Data Source="' + txtInputFile.Text + '";' +
          'Extended Properties="Excel 12.0 Xml;HDR=No;IMEX=1"'
      else
        raise (Exception.Create(
          'The Excel Version "' + CurrToStr(FExcelVersion) +
          '" is not supported by the Excel Conversion.'));
    
      AdoConnection1.Connected := False;
      AdoConnection1.ConnectionString := strConn;
    
      try
        SheetNameList := TStringList.Create();
        try
          AdoConnection1.Open;
    
          ADOConnection1.GetTableNames(SheetNameList, False);
          FSheetName := SheetNameList[0];
        except
          ShowMessage('Unable to connect to Excel!' + AsciiCRLF +
                      'Make sure the Excel file ' + txtInputFile.Text + ' exists with '+
                      'sheet name ' + FSheetName + '.');
          raise;
        end;
      finally
        FreeAndNil(SheetNameList);
      end;
    
    end;
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to connect to an Active Directory from Activiti, using Apache Directory's LDAP
Ok I am trying to connect to an Outlook calendar from C# using the
I've been trying to connect Excel to online mysql database. Im using 5.1 DSN
I am trying to extract a table of values from an excel (2003) spreadsheet
I'm trying to connect excel on a database which has the following query. SELECT
Im trying to connect MySql from VB.NET in visual basic 2010. I wanted to
I am trying to connect to a MySQL Server using JDBC tool in java
I'm trying to connect to a FTP using Apaches FTPSClient but I keep getting
Trying to connect to sql server 2005 with delphi 2010 gives me the following
When trying to connect to my database server, i encounter the problem of unknown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.