RSS

Excel to C#

16 Sep

Сайн байна уу? Бяцхаан коод🙂
Хэрэг болж магад гэж бодлоо.

using System.Data.OleDb;

public void loadFromExcel()
{
OleDbDataAdapter oleDA;
DataSet ds;
string ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePathName@;Persist Security Info=True;Extended Properties=EXCEL 8.0″;

using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
conn.Open();

oleDA = new OleDbDataAdapter(“select * from [sheetname$]”, conn);

ds = new DataSet();

oleDA.Fill(ds);

dt = ds.Tables[0];

this.gridControl1.DataSource = dt;
}

 
1 Comment

Posted by on September 16, 2009 in .NET Visual studio, My

 

One response to “Excel to C#

  1. MR.Dollar

    July 9, 2010 at 5:05 pm

    sheets gedeg dr ni sheet.n sheet n ner bh yum u?-

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: