Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team ,

I imported excel data to gridview successfully, but i need the excel rowheader as gridview rowheader with out doing a loop, as my excel having more than 60,000 records, looping will be very slow,

my code is


string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='"+ System.IO.Path.GetDirectoryName(path) + "';Extended Properties=\"Text;HDR=YES;FMT=Delimited\";";// "//Excel 8.0;";

DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

DbDataAdapter adapter = factory.CreateDataAdapter();

DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = "select * from [" + System.IO.Path.GetFileName(path) + "]";

DbConnection connection = factory.CreateConnection();
connection.ConnectionString = connectionString;

selectCommand.Connection = connection;

adapter.SelectCommand = selectCommand;

adapter.Fill(data);

Gridview.DataSource = data.Tables[0];

The above code is importing the all the fields of excel, but i need the excel rowID column

i mean row header, which is the identity column in excel, the first column

can any one helps me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900