请问怎样可以获得excel中Sheet1位置的名称值?
以下是在aspx中取excel的,但要事先知道excel表中Sheet1位置的值才可以,请问怎样通过C#取到Sheet1位置上的名称值?
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\aa.xls;Extended Properties=Excel 8.0;" ;
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1, "XLData");
DataGrid1.DataSource = objDataset1.Tables[0].DefaultView;
DataGrid1.DataBind();
objConn.Close();
}
</script>
<body>
<h3><font face="宋体">DataGrid 控件的简单选择</font></h3>
<ASP:DataGrid id="DataGrid1" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="宋体"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</body>
</html>