Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

string strConn = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + filename + ";Extended Properties="Excel 12.0 Xml;HDR=Yes;IMEX=1";";

I search on google, and got no results. I think the default value is 2, but I am not sure.

Anyone can help me? Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
812 views
Welcome To Ask or Share your Answers For Others

1 Answer

While I didn't find information on a default, the comment from @Bao helps explain the IMEX setting. According to Microsoft Knowlege Base Article 194124 the IMEX parameter stands for IMport EXport mode. Here's a quote from the article:

The possible settings of IMEX are:

 0 is Export mode
 1 is Import mode
 2 is Linked mode (full update capabilities)

In plain English, you might use IMEX=0 for Writes, IMEX=1 for Read-Only, and IMEX=2 for Modifications / Updates (Read, Change, Save Changes).

I notice that this question is tagged for Excel, but the Microsoft.ACE.OLEDB Provider allows connections to many types of data sources supported by the Access Database Engine including Access (*.accdb), Excel (*.xlsx), SharePoint Lists, etc. The IMEX parameter will impact these other types of data sources in similar ways.


Update August 2017. Additional comments on IMEX Extended Properties as mentioned in another document ADO.NET Connection String Syntax (docs.microsoft.com) under heading "Connecting to Excel":

In the [example] connection string, the Extended Properties keyword sets properties that are specific to Excel. "HDR=Yes;" indicates that the first row contains column names, not data, and "IMEX=1;" tells the driver to always read "intermixed" data columns as text.

I believe that the previous KB article still applies and the IMEX setting is more generally applied as export/import/linked to other non-excel data sources in data source connection strings. Also note that the KB article indicates that the "ImportMixedTypes" setting may be changed via registry - this leads me to believe that this second article should be mostly ignored in favor of the KB to explain the IMEX setting. The related registry settings are documented for Access Connectivity Engine (ACE) Excel Driver @ Windows Registry Settings for External Data Sources - Initializing the Microsoft Excel Driver.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...