2024年3月9日发(作者:)

先读取EXCEL中的数据

private void btnView_Click(object sender, rgs e)

{

urce = null;

FileDialog dlgOpen = new OpenFileDialog();

="Excel Files (*.xls)|*.xls";

if(alog() == )

{

=me;

string strCon = "Provider = .4.0

Source = "+()+";Extended Properties=Excel

OleDbConnection myConn = new OleDbConnection();

try

{

; Data

8.0" ;

= rsor;

//创建一个数据Excel连接

******************************************************************

myConn = new OleDbConnection ( strCon ) ;

string strCom = " SELECT * FROM [Sheet1$]" ;

();

//打开连接得到数据集合

();

OleDbDataAdapter myCommand = new OleDbDataAdapter

( strCom , myConn ) ;

( oDS , "[Sheet1$]" ) ;

//关闭连接

( ) ;

if (![0].ns("Insert Result"))