C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Databinding »

Read from excel file and display in grid


Posted Date: 07 Aug 2009    Resource Type: Code Snippets    Category: Databinding
Author: Debasmit SamalMember Level: Gold    
Rating: 1 out of 5Points: 6



Description :


This code shows how to Read from excel file and display in grid

Code :
     
string strExcelConn;
strExcelConn= "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Documents and Settings\\Deb\\Desktop\\New XML work\\0UIIAP0010_2009-02_RENEWAL_REPORT (1).xls;" +
"Extended Properties=Excel 8.0;";
//use the $ after the object you reference in the Excel sheet
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [TML 2009-02$]", strExcelConn);

DataSet myDSet = new DataSet();
myCommand.Fill(myDSet , "ExcelTableInfo");
DataGrid1.DataSource = myDSet .Tables["ExcelTableInfo"].DefaultView;
DataGrid1.DataBind();



Responses

Author: Filip    03 Sep 2009Member Level: Silver   Points : 2
OLEDB is slow way to read Excel files and export DataGrid. You may want to try with 3rd party components like for example GemBox Excel .NET component. Here's an example how you can read Excel files in C#/VB and export DataGrid to Excel in C#/VB.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Read from Excel  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Data binding using DataAdapter and Datareader
Previous Resource: DataBase Operation In Java Using JDBC
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use