如何在vb.net中连接到Excel数据

如何在vb.net中连接到Excel数据

问题描述:

如何在vb.net中连接到Excel数据.
我需要一个示例代码.

在此先感谢您.

how to connect to excel data in vb.net.
i need a sample code.

Thanks in Advance.

感谢您的提问.请遵循以下代码.

Thanks for your question. Follow bellow code.

Dim cn as ADODB.Connection
Set cn = New ADODB.Connection
With cn
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
"Extended Properties=Excel 8.0;"
    .Open
End With




参考: http://support.microsoft.com/kb/257819 [




Ref:http://support.microsoft.com/kb/257819[^]


Thanks,
Mamun