最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 获取excel工作溥数据与连接方法(vb.net,c#)
时间:2022-06-25 06:04:47 编辑:袖梨 来源:一聚教程网
asp教程.net 获取excel工作溥数据与连接方法
c#读取excel数据表方法
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
void Page_Load(object sender, EventArgs e) {
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:Yourspreadsheet.xls; Extended Properties=""Excel 8.0;HDR=Yes"";";
string CommandText = "select * from [Book$]";
OleDbConnection myConnection = new OleDbConnection(ConnectionString);
OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
DataGrid1.DataBind();
myConnection.Close();
}
Simple Data Report
vb.net读取excel数据方法
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.OleDb" %>
Reading from an Excel Workbook
Reading from an Excel Workbook