cnblogs/dcrenl/C#连接EXCEL和ACCESS字符串2003及2007版.html
2024-09-24 12:43:01 +08:00

29 lines
4.4 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div id="sina_keyword_ad_area2" class="articalContent ">
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;"><strong>97-2003版本</strong></p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">EXCEL</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=文件位置;ExtendedProperties=Excel 8.0;HDR=Yes;IMEX=1</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">ACCESS</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=文件位置;JetOLEDB:Database Password=密码;</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;"><strong>2007版本</strong></p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">EXCEL</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">Provider=<strong><span style="color: #ff0000;">Microsoft.Ace.OleDb.12.0</span></strong>;DataSource=文件位置;Extended Properties=<span style="color: #ff0000;"><strong>Excel12.0</strong></span>;HDR=Yes;IMEX=1</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">ACCESS</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">Provider=<strong><span style="color: #ff0000;">Microsoft.Ace.OleDb.12.0</span></strong>;DataSource=文件位置;Jet OLEDB:Database Password=密码;</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">【其他说明】</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">HDR=Yes/NO 表示是否将首行做标题。</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">IMEX 表示是否强制转换为文本</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">特别注意</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">Extended Properties='Excel 8.0;HDR=yes;IMEX=1'</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">A HDR ( HeaDer Row )设置</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">若指定值为Yes代表 Excel 档中的工作表第一行是栏位名称</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">若指定值為 No代表 Excel 档中的工作表第一行就是資料了,沒有栏位名称</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">BIMEX ( IMport EXport mode )设置</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">IMEX 有三种模式,各自引起的读写行为也不同,容後再述:</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">0 is Export mode</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">1 is Import mode</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">2 is Linked mode (full update capabilities)</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">我这里特别要说明的就是 IMEX 参数了,因为不同的模式代表著不同的读写行为:</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">当 IMEX=0 时为&ldquo;汇出模式&rdquo;,这个模式开启的 Excel 档案只能用来做&ldquo;写入&rdquo;用途。</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">当 IMEX=1 时为&ldquo;汇入模式&rdquo;,这个模式开启的 Excel 档案只能用来做&ldquo;读取&rdquo;用途。</p>
<p style="margin: 10px auto; font-family: verdana,Arial,Helvetica,sans-serif; line-height: 25px;">当 IMEX=2 时为&ldquo;连結模式&rdquo;,这个模式开启的 Excel 档案可同时支援&ldquo;读取&rdquo;&ldquo;写入&rdquo;用途。</p>
</div>