Hello All,
Here I am posting code, which will read through a Excel Document. This code will traverse through all sheets of Excel spread sheet, No matter what name they will have.
This uses OLEDB connection to read through excel sheets.
using System.Data.OleDb;<br /><br />protected void Page_Load(object sender, EventArgs e)<br />{<br /> GetExcelSheetNames("Path");<br />}<br /><br />private void GetExcelSheetNames(string excelFile)<br />{<br /> OleDbConnection objConn = null;<br /> System.Data.DataTable dt = null;<br /> try<br /> {<br /> DataSet ds = new DataSet();<br />
In .aspx file
<asp:GridView ID="GridView1" <br /> runat="server" <br /> AllowPaging="true" <br /> PagerSettings-Mode="Numeric" <br /> PagerSettings-Position="Bottom" <br /> PagerStyle-Font-Size="Medium" <br /> PageSize = "10" <br /> OnPageIndexChanging="GridView1_PageIndexChanging" ><br /></asp:GridView><br />
This will have the data from the excel document in a gridview, with paging.
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.
The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.