none
Microsoft Interop Excel connection in .NET C# RRS feed

  • Question

  • Hi,

    I am trying to import an excel 2010 XLSM file into the database in C# MVC.NET. But I am getting the error - "External table is not in the expected format".

    I am using the ACE provider in the connecting string and also have installed the ACE EXE 64 bit. I have tried XLSX files and they didn't work either. I got the same error.

    I will be grateful if someone can help

    Connection string
    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0 XML;HDR=Yes;'";

    Regards,

    Karthik

    Wednesday, January 21, 2015 8:55 AM

Answers

  • Hello,

    With your provided connection, I tested with a sample excel 2010 file, however, it could work fine. From your description, it seems that you are trying to read a xlsm file, as far as I know, for reading this kind of files, we need to enable the macros as:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsm;
    
    Extended Properties="Excel 12.0 Macro;HDR=YES";
    

    Reference from http://www.connectionstrings.com/excel-2007/

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 22, 2015 7:45 AM
    Moderator