本文將告訴您,如何使用 ADO.NET 從 Microsoft Excel
活頁簿中擷取資料、修改現有活頁簿中的資料,或是將資料加入新的活頁簿中。如果要使用 ADO.NET 存取 Excel 活頁簿,您可以利用 Jet OLE DB
Provider;本文提供所需要的資訊,當 Excel 是目標資料來源時,就可以使用 Jet OLE DB
Provider。
如何將 Microsoft Excel 活頁簿與 Jet OLE DB Provider 搭配使用
Microsoft Jet 資料庫引擎可以透過可安裝的索引循序存取方法 (ISAM,Installable Indexed
Sequential Access Method) 驅動程式,使用其他資料庫的檔案格式存取資料,例如 Excel 活頁簿。如果要開啟 Microsoft
Jet 4.0 OLE DB Provider 所支援的外部格式,請在連線的擴充屬性中指定資料庫類型。Jet OLE DB Provider 支援
Microsoft Excel 活頁簿的下列資料庫類型:
Excel 3.0
Excel 4.0
Excel 5.0
Excel 8.0
注意:在 Microsoft Excel 5.0 和 7.0 (95) 活頁簿中請使用 Excel 5.0 來源資料庫類型,而在
Microsoft Excel 8.0 (97)、9.0 (2000) 和 10.0 (2002) 活頁簿中則使用 Excel 8.0 來源資料庫類型。
本文中的範例是使用 Excel 2000 和 Excel 2002 的活頁簿格式。
連線字串
如果要使用 Jet OLE DB Provider 存取 Excel 活頁簿,請使用含有下列語法的連線字串:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties="Excel 8.0;HDR=YES;"
在連線字串中,請於
Data Source 參數中指定活頁簿的完整路徑與檔案名稱。
Extended Properties 參數可能包含兩個屬性:ISAM 版本的屬性和顯示表格中是否包括標頭的屬性。
使用 Excel
活頁簿時,依照預設,第一列的固定範圍是標頭列 (或欄位名稱)。如果第一個範圍中並未包含標頭,您可以在連線字串的擴充屬性中指定 HDR=NO。
如果您在連線字串中指定 HDR=NO,Jet OLE DB Provider 會自動為您命名該欄位 (F1 代表第一個欄位,F2
代表第二個欄位,以此類推)。
資料類型
與傳統資料庫不同的是,並沒有一個直接的方法,可以指定 Excel 表格中欄的資料類型。相反地,OLE DB Provider
可以掃描欄中的八個資料列,以便
猜測欄位的資料類型。您可以在連線字串的擴充屬性中,於 MAXSCANROWS 設定內指定介於 (1) 到 (16)
的值,以變更要掃描的資料列數目。
表格命名慣例
在 Excel 活頁簿中有幾種參照表格 (或範圍) 的方法:
注意:工作表名稱後面的錢幣符號是表格存在的指示。如果您建立一個新的表格,則依照本文中<
建立新的活頁簿和表格>一節所述,請勿使用錢幣符號。
如何將 Excel 活頁簿當做 ADO.NET 資料來源來使用
擷取記錄
您可以使用 ADO.NET 中的兩種方法之一來擷取資料庫記錄:使用
Dataset 或
DataReader。
Dataset 是從資料來源擷取的記錄快取。
Dataset 中的資料通常是資料庫實際資料之精簡版。然而,您可以依照使用實際資料的相同方式,使其進行工作,並同時與實際資料庫保持離線狀態。
除了擷取資料之外,您也可以使用
Dataset,在其下的資料庫上執行更新作業。
或者,您可以使用
DataReader 從資料庫中擷取唯讀且順向的資料流。使用
DataReader 程式時,因為記憶體中一次只存有一筆資料列,所以能提高效能並降低系統負荷。如果您要擷取大量資料,並且不打算變更其下的資料庫時,
DataReader 會比
Dataset 實用。
新增與更新記錄
您可以下列三種方法之一使用 ADO.NET 在活頁簿中插入和更新記錄:
- 直接執行命令,以便一次插入或更新一筆記錄。如果要執行這項操作,您可以在連線上建立 OLEDbCommand 物件,並將 CommandText 屬性設定為插入記錄的有效命令
INSERT INTO [Sheet1$] (F1, F2) values ('111', 'ABC') ,或是更新記錄的命令
UPDATE [Sheet1$] SET F2 = 'XYZ' WHERE F1 = '111'
,然後呼叫 ExecuteNonQuery 方法。 - 變更填滿 Excel 活頁簿表格或查詢的 DataSet,然後呼叫 DataAdapter 的 Update 方法,以解析 DataSet 傳回活頁簿的變更。然而,如果要使用 Update 方法解析變更,您必須為 DataAdapter 的 InsertCommand
INSERT INTO [Sheet1$] (F1, F2) values (?, ?)
和 UpdateCommand 設定參數化命令:
UPDATE [Sheet1$] SET F2 = ? WHERE F1 = ?
之所以要參數化 INSERT 和 UPDATE 命令,是因為 OleDbDataAdapter 並不會提供 Excel 活頁簿之鍵值和索引資訊;而在沒有鍵值和索引欄位的情況下,CommandBuilder
無法為您自動產生命令。 - 從另一個資料來源 匯出 至 Excel 活頁簿使其他資料來源可以與 Jet OLE DB Provider 搭配使用。以此方式與 Jet OLE DB
Provider 搭配使用的資料來源包括了文字檔、Microsoft Access 資料庫,當然也包括其他 Excel 活頁簿。藉由單一 INSERT
INTO 命令,您可以從另一個表格或查詢將資料匯出至活頁簿中:
INSERT INTO [Sheet1$] IN 'C:\Book1.xls' 'Excel 8.0;' SELECT * FROM MyTable"
INSERT INTO 需要已存在的目標表格 (或工作表);而資料會附加在目標表格上。
您也可以使用
SELECT..INTO 將表格或查詢匯出至活頁簿中:
SELECT * INTO [Excel 8.0;Database=C:\Book1.xls].[Sheet1] FROM [MyTable]
當您使用 SELECT..INTO 時,如果目標表格或活頁簿不存在,其會為您建立。如果在 SELECT..INTO
命令執行之前表格已經存在,您將會收到錯誤訊息。
本文稍後的<
程式碼範例>一節中將會說明如何在活頁簿中新增和更新記錄。
刪除記錄
雖然 Jet OLE DB Provider 允許您在 Excel 活頁簿中插入和更新記錄,但是並不允許 DELETE 作業。
如果您嘗試在一或多筆記錄上執行 DELETE 作業,則會收到下列錯誤訊息:
Deleting data in a
linked table is not supported by this ISAM. (此 ISAM 不支援刪除連結表格中的資料)。
此限制是將 Excel 活頁簿視為資料庫處理的自然現象。
建立活頁簿和表格
如果要在 Excel 活頁簿中建立表格,請執行 CREATE TABLE 命令:
CREATE TABLE Sheet1 (F1 char(255), F2 char(255))
當您執行此命令時,即會以命令中所指定的表格名稱建立新的工作表。如果連線的活頁簿不存在,則也會加以建立。
<
程式碼範例>一節將告訴您,如何使用 CREATE TABLE
命令建立新的活頁簿和表格。
逐步說明
程式碼範例
- 啟動新的 Visual Basic .NET Windows 應用程式專案。
依照預設,會建立 Form1。 - 在 Form1 中新增六個 RadioButton 控制項和一個 Button 控制項。
- 選取所有 RadioButton 控制項,並將 Size 屬性設定為 200,24。
- 在 [檢視] 功能表上,按一下 [程式碼]。
- 將下列資料行新增至程式碼模組的最開頭處:
Imports System.Data.OleDb
- 將下列程式碼插入至 Form 類別 中:
Private m_sConn1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\ExcelData1.xls;" & _
"Extended Properties=""Excel 8.0;HDR=YES"""
Private m_sConn2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\ExcelData2.xls;" & _
"Extended Properties=""Excel 8.0;HDR=YES"""
Private m_sNorthwind = _
"C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb"
Private m_sAction As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RadioButton1.Text = "Create_Workbook"
RadioButton2.Text = "Retrieve_Records"
RadioButton3.Text = "Add_Records"
RadioButton4.Text = "Update_Records"
RadioButton5.Text = "Update_Individual_Cells"
RadioButton6.Text = "Use_External_Source"
Button1.Text = "Go!"
End Sub
Private Sub RadioButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles RadioButton1.Click, RadioButton2.Click, RadioButton3.Click, _
RadioButton4.Click, RadioButton5.Click, RadioButton6.Click
m_sAction = sender.Text'Store the text for the selected radio button
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
' Call the associated routine to add/update/modify the workbook.
Select Case m_sAction
Case "Create_Workbook" : Create_Workbook()
Case "Retrieve_Records" : Retrieve_Records()
Case "Add_Records" : Add_Records()
Case "Update_Records" : Update_Records()
Case "Update_Individual_Cells" : Update_Individual_Cells()
Case "Use_External_Source" : Use_External_Source()
End Select
Catch ex As OleDbException
Dim er As OleDbError
For Each er In ex.Errors
MsgBox(er.Message)
Next
Catch ex2 As System.InvalidOperationException
MsgBox(ex2.Message)
End Try
End Sub
Public Sub Create_Workbook()
' If the workbooks already exist, prompt to delete.
Dim answer As MsgBoxResult
If Dir("C:\ExcelData1.xls") <> "" Or Dir("C:\ExcelData2.xls") <> "" Then
answer = MsgBox("Delete existing workbooks (C:\ExcelData1.xls and " & _
"C:\ExcelData2.xls)?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
If Dir("C:\ExcelData1.xls") <> "" Then Kill("C:\ExcelData1.xls")
If Dir("C:\ExcelData2.xls") <> "" Then Kill("C:\ExcelData2.xls")
Else
Exit Sub
End If
End If
'==========================================================================
' Create a workbook with a table named EmployeeData. The table has 3
' fields: ID (char 255), Name (char 255) and Birthdate (date).
'==========================================================================
Dim conn As New OleDbConnection()
conn.ConnectionString = m_sConn1
conn.Open()
Dim cmd1 As New OleDbCommand()
cmd1.Connection = conn
cmd1.CommandText = "CREATE TABLE EmployeeData (Id char(255), Name char(255), BirthDate date)"
cmd1.ExecuteNonQuery()
cmd1.CommandText = "INSERT INTO EmployeeData (Id, Name, BirthDate) values ('AAA', 'Andrew', '12/4/1955')"
cmd1.ExecuteNonQuery()
conn.Close()
'==========================================================================
' Create a workbook with a table named InventoryData. The table has 3
' fields: Product (char 255), Qty (float) and Price (currency).
'==========================================================================
conn.ConnectionString = m_sConn2
conn.Open()
Dim cmd2 As New OleDbCommand()
cmd2.Connection = conn
cmd2.CommandText = "CREATE TABLE InventoryData (Product char(255), Qty float, Price currency)"
cmd2.ExecuteNonQuery()
cmd2.CommandText = "INSERT INTO InventoryData (Product, Qty, Price) values ('Cola', 200, 1.35)"
cmd2.ExecuteNonQuery()
cmd2.CommandText = "INSERT INTO InventoryData (Product, Qty, Price) values ('Chips', 550, 0.89)"
cmd2.ExecuteNonQuery()
conn.Close()
' NOTE: You can ALTER and DROP tables in a similar fashion.
End Sub
Public Sub Retrieve_Records()
'==========================================================
'Use a DataReader to read data from the EmployeeData table.
'==========================================================
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim cmd1 As New System.Data.OleDb.OleDbCommand("Select * From [EmployeeData$]", conn1)
Dim rdr As OleDbDataReader = cmd1.ExecuteReader
Debug.WriteLine(vbCrLf & "EmployeeData:" & vbCrLf & "=============")
Do While rdr.Read()
Debug.WriteLine(System.String.Format("{0,-10}{1, -15}{2}", _
rdr.GetString(0), rdr.GetString(1), _
rdr.GetDateTime(2).ToString("d")))
Loop
rdr.Close()
conn1.Close()
'========================================================
'Use a DataSet to read data from the InventoryData table.
'========================================================
Dim conn2 As New OleDbConnection(m_sConn2)
Dim da As New OleDbDataAdapter("Select * From [InventoryData$]", conn2)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
Debug.WriteLine(vbCrLf & "InventoryData:" & vbCrLf & "==============")
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows'Show results in output window
Debug.WriteLine(System.String.Format("{0,-15}{1, -6}{2}", _
dr("Product"), dr("Qty"), dr("Price")))
Next
conn2.Close()
End Sub
Public Sub Add_Records()
'==========================================================================
' Run an INSERT INTO command to add new records to the workbook.
'==========================================================================
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conn1
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values ('CCC', 'Charlie', '10/14/48')"
cmd.ExecuteNonQuery()
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values ('DDD', 'Deloris', '7/19/98')"
cmd.ExecuteNonQuery()
conn1.Close()
'====================================================================
'Use the InsertCommand object to add new records to the InventoryData
'table.
'====================================================================
Dim conn2 As New OleDbConnection(m_sConn2)
Dim da As New OleDbDataAdapter("Select * From [InventoryData$]", conn2)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "MyExcelTable")
' Generate the InsertCommand and add the parameters for the command.
da.InsertCommand = New OleDbCommand( _
"INSERT INTO [InventoryData$] (Product, Qty, Price) VALUES (?, ?, ?)", conn2)
da.InsertCommand.Parameters.Add("@Product", OleDbType.VarChar, 255, "Product")
da.InsertCommand.Parameters.Add("@Qty", OleDbType.Double).SourceColumn = "Qty"
da.InsertCommand.Parameters.Add("@Price", OleDbType.Currency).SourceColumn = "Price"
' Add two new records to the dataset.
Dim dr As DataRow
dr = ds.Tables(0).NewRow
dr("Product") = "Bread" : dr("Qty") = 390 : dr("Price") = 1.89 : ds.Tables(0).Rows.Add(dr)
dr = ds.Tables(0).NewRow
dr("Product") = "Milk" : dr("Qty") = 99 : dr("Price") = 2.59 : ds.Tables(0).Rows.Add(dr)
' Apply the dataset changes to the actual data source (the workbook).
da.Update(ds, "MyExcelTable")
conn2.Close()
End Sub
Public Sub Update_Records()
'==========================================================================
' Run an UPDATE command to change a record in the EmployeeData
' table.
'==========================================================================
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conn1
cmd.CommandText = "UPDATE [EmployeeData$] " & _
"SET NAME = 'Aaron', BirthDate = '5/4/1975' WHERE ID = 'AAA'"
cmd.ExecuteNonQuery()
conn1.Close()
'====================================================================
' Use the UpdateCommand object to modify records in the InventoryData
' table.
'====================================================================
Dim conn2 As New OleDbConnection(m_sConn2)
Dim da As New OleDbDataAdapter("Select * From [InventoryData$]", conn2)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "MyInventoryTable")
' Generate the UpdateCommand and add the parameters for the command.
da.UpdateCommand = New OleDbCommand( _
"UPDATE [InventoryData$] SET Qty = ?, Price=? WHERE Product = ?", conn2)
da.UpdateCommand.Parameters.Add("@Qty", OleDbType.Numeric).SourceColumn = "Qty"
da.UpdateCommand.Parameters.Add("@Price", OleDbType.Currency).SourceColumn = "Price"
da.UpdateCommand.Parameters.Add("@Product", OleDbType.VarChar, 255, "Product")
' Update the first two records.
ds.Tables(0).Rows(0)("Qty") = 1000
ds.Tables(0).Rows(0)("Price") = 10.1
ds.Tables(0).Rows(1)("Qty") = 2000
ds.Tables(0).Rows(1)("Price") = 20.2
' Apply the dataset changes to the actual data source (the workbook).
da.Update(ds, "MyInventoryTable")
conn2.Close()
End Sub
Public Sub Update_Individual_Cells()
'==========================================================================
' Update individual cells on the EmployeeData worksheet;
' specifically, cells F3, G3, and I4 are modified.
'==========================================================================
' NOTE: The connection string indicates that the table does *NOT*
' have a header row.
Dim conn As New System.Data.OleDb.OleDbConnection(m_sConn1.Replace("HDR=YES", "HDR=NO"))
conn.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conn
cmd.CommandText = "UPDATE [EmployeeData$F3:G3] SET F1 = 'Cell F3', F2 = 'Cell G3'"
cmd.ExecuteNonQuery()
cmd.CommandText = "UPDATE [EmployeeData$I4:I4] SET F1 = 'Cell I4'"
cmd.ExecuteNonQuery()
conn.Close()
End Sub
Public Sub Use_External_Source()
' Open a connection to the sample Northwind Access database.
Dim conn As New System.Data.OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & m_sNorthwind & ";")
conn.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conn
'=======================================================================
' Run an INSERT..INTO command on the Northwind database to append
' the records from a table/query to an existing table in the Excel
' workbook.
'=======================================================================
cmd.CommandText = "INSERT INTO [EmployeeData$] IN 'C:\ExcelData1.xls' 'Excel 8.0;'" & _
"SELECT EmployeeID AS ID, FirstName AS Name, BirthDate FROM Employees"
cmd.ExecuteNonQuery()
'==========================================================================
' Run a SELECT..INTO command on the Northwind database to insert
' all the records from a table/query into a new sheet in the Excel
' workbook.
'==========================================================================
cmd.CommandText = "SELECT * INTO [Excel 8.0;Database=C:\ExcelData2.xls].[ProductSales]" & _
"FROM [Product Sales for 1997]"
cmd.ExecuteNonQuery()
conn.Close()
End Sub - 如有必要,請將程式碼中的 m_sNorthwind 成員路徑修改為指向 Access 範例資料庫
Northwind。
進行試驗
- 在 [檢視] 功能表上,指向 [其他視窗],然後按一下 [輸出] 以顯示 [輸出] 視窗。
- 按下 F5 以建置並執行該程式。
- 按一下 Create_Workbook,然後再按一下 [執行]。Create_Workbook 程序會執行 CREATE TABLE 命令,以建立兩個新的活頁簿:C:\ExcelData1.xls 和
C:\ExcelData2.xls。ExcelData1.xls 包含一個名為 EmployeeData 的工作表 (表格),而 ExcelData2.xls
包含一個名為 InventoryData 的工作表 (表格)。該表格填滿了記錄。
注意:在此測驗的其餘每個步驟中,請在 Excel 中開啟活頁簿以檢查結果。或者,按一下 Retrieve_Records,檢視 Visual Studio .NET [輸出] 視窗的表格內容。 - 按一下 Retrieve_Records,然後按一下 [執行]。Retrieve_Records 程序會展開表格中的記錄,並將其顯示在 [輸出] 視窗,與此類似:
EmployeeData:
=============
AAA Andrew 12/4/1955
InventoryData:
==============
Cola 200 1.35
Chips 550 0.89
- 按一下 Add_Records,然後按一下 [執行]。Add_Records 常式會新增兩筆記錄至每個表格中:
EmployeeData:
=============
AAA Andrew 12/4/1955
CCC Charlie 10/14/1948
DDD Deloris 7/19/1998
InventoryData:
==============
Cola 200 1.35
Chips 550 0.89
Bread 390 1.89
Milk 99 2.59
- 按一下 Update_Records,然後按一下 [執行]。Update_Records 常式會更新兩筆記錄至每個活頁簿中:
EmployeeData:
=============
AAA Aaron 5/4/1975
CCC Charlie 10/14/1948
DDD Deloris 7/19/1998
InventoryData:
==============
Cola 1000 10.1
Chips 2000 20.2
Bread 390 1.89
Milk 99 2.59
- 按一下 Update_Individual_Cells,然後按一下 [執行]。Update_Individual_Cells 常式會修改 ExcelData1.xls 中 EmployeeData 工作表的特定儲存格;明確地說是更新儲存格 F3、G3 和
I4。
- 按一下 Use_External_Source,然後按一下 [執行]。當您使用 INSERT..INTO 命令時,Use_External_Source 常式會將 Northwind 表格「Employees」中的記錄,附加至 ExcelData1.xls 中的
EmployeeData 工作表。然後,Use_External_Source 使用 SELECT..INTO 命令,在包含所有 Northwind 表格「Products」記錄的 ExcelData2.xls
中建立新的表格 (或工作表)。
注意:如果您不只一次按下 Use_External_Source,因為並未辨識或強制主索引鍵,所以 Employees 清單會被附加好幾次。
儲存格格式
如果您使用 ADO.NET 新增或更新現有活頁簿中的記錄,則可以將儲存格格式套用至使用新增或更新記錄的活頁簿。
當您更新活頁簿中現有的記錄 (或資料列) 時,會保留儲存格格式。而當您在活頁簿中插入一筆新的記錄 (或資料列)
時,新的記錄會沿用上一個資料列的格式。
下列程序將告訴您,如何利用程式碼範例在活頁簿中使用格式:
- 按下 F5 以建置並執行該範例。
- 在 Form1 上,按一下 Create_Workbook,然後按一下 [執行]。
- 啟動 Microsoft Excel,然後開啟 C:\ExcelData1.xls。
- 將粗體字型樣式套用至儲存格 A2。
- 將斜體、底線樣式套用至儲存格 B2,並置中對齊。
- 將完整日期格式套用至儲存格 C2。
- 儲存並關閉 C:\ExcelData1.xls。
- 在 Form1 上,按一下 Add_Records,然後按一下 [執行]。
- 在 Excel 中開啟
C:\ExcelData1.xls,並且注意兩筆新的資料列是否已沿用了第一筆資料列的格式。
限制
下列是有關 Excel 資料來源的 Jet OLE DB Provider 限制:
- 您無法使用 ADO.NET 在儲存格中插入公式。
- Jet OLE DB Provider 無法提供 Excel 活頁簿中表格的鍵值或索引資訊。基於此原因,您無法使用
CommandBuilder 在 Excel 活頁簿中自動產生記錄的更新和插入。
如需詳細資訊,請按一下下面的文件編號,檢視 Microsoft Knowledge Base 中的文件:
316756
(http://support.microsoft.com/kb/316756/ZH-TW/
)
PRB:Error Using ADO.NET OLEDbDataAdapter to Modify Excel Workbook
257819
(http://support.microsoft.com/kb/257819/ZH-TW/
)
HOWTO:從 Visual Basic 或 VBA 搭配使用 ADO 與 Excel 資料
306023
(http://support.microsoft.com/kb/306023/ZH-TW/
)
HOW TO:Transfer Data to an Excel Workbook Using Visual C# .NET
311731
(http://support.microsoft.com/kb/311731/ZH-TW/
)
HOW TO:使用 ASP.NET、ADO.NET 和 Visual Basic .NET 查詢與顯示 Excel 資料
306572
(http://support.microsoft.com/kb/306572/ZH-TW/
)
HOW TO:使用 ASP.NET、ADO.NET 及 Visual C# .NET 查詢及顯示 Excel 資料
278973
(http://support.microsoft.com/kb/278973/ZH-TW/
)
SAMPLE:ExcelADO 示範使用 ADO 在 Excel 活頁簿讀取和寫入資料的方法
文章編號: 316934 - 上次校閱: 2003年11月24日 - 版次: 4.0
這篇文章中的資訊適用於:
- Microsoft Excel 2000 Standard Edition
- Microsoft Visual Basic .NET 2002 Standard Edition
- Microsoft ADO.NET (included with the .NET Framework)
- Microsoft Excel 2002 Standard Edition
- Microsoft Office Excel 2003
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。