I know it seem's easy, but i dont know why i cannot find any example or tutorials on how to display data from excel into a label or text box from internet.
This program will read from excel and display the content inside to a label and read to text file. I can manage to do write into text file only left on how to display into a label.
any references or solution might be useful adn very thankful...thanx all.
Here codes for the references:
//***create connection using axcel
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=F:\\pass.xls;Extended Properties=
""Excel 8.0;HDR=YES;""";
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);
//write into text file
StreamWriter tw = File.AppendText("C:\\test.txt");
OleDbDataReader reader = objCmdSelect.ExecuteReader();
while (reader.Read())
{
tw.Write(reader["id"].ToString());
tw.Write(", " + reader["pass"].ToString());
}
tw.WriteLine(DateTime.Now);
tw.WriteLine("---------------------------------");
tw.Close();
reader.Close();
objConn.Close();
}

New Topic/Question
Reply




MultiQuote



|