Load an Excel file

xiaoxiao2021-04-01  223

Load an Excel file with DataGrid

First create a database connection

OLEDBCONNECTION CN = New OLEDBCONNECTION ("provider = microsoft.jet.Oledb.4.0; data source =" server.mappath ("xxxxx.xls") "; extended profment = excel 8.0;"); // xxxxx.xls Excel file

OLEDBADAPTER ADA = New OLEDBADAPTER ("Select * from [Sheet1 $], CN); // Sheet1 Which subfold

DataSet DS = New Dataset ();

Ada.fill (DS, "TTTT");

This.DataGrid1.datasource = ds.table [0] .defaultView;

THIS.DATAGRID1.DATABIND ();

// This will complete a simple load an Excel file.

转载请注明原文地址:https://www.9cbs.com/read-131111.html

New Post(0)