Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i got lists of data that import from excel and i want to store it in node for example

Pro_ID[0] duration[0] pressodesor[0] in a node how can i do it anyone please help

well i didn't know where to start ...... i got an lists that store data. i got like 4 lists.

all list is linked for example list at index 0 are all the information to the first link.

..................................................................................

here is my code to store the data in excel to list

..................................................................................
private void button1_Click(object sender, EventArgs e)
{
try
{
{
openFileDialog1.Filter = "Excel Sheet(*.xlsx)|*.xlsx|All Files(*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string FileName = openFileDialog1.FileName; // เอาทั้งชื่อและนามสกุล path.GetFileName
//string path = // Application.StartupPath + @"\MyExcel.xlsx"; // Server.MapPath("File/MyExcel.xlsx");
string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName;
connstr += ";Extended Properties=Excel 12.0;";

string strSQL = "SELECT * FROM [Sheet1$]";
OleDbConnection con = new OleDbConnection(connstr);
con.Open();
OleDbCommand com;
com = new OleDbCommand(strSQL, con);
OleDbDataReader odr;
com.Parameters.Clear();
odr = com.ExecuteReader();
DataTable dt = new DataTable();
if (odr.HasRows)
{
dt.Load(odr);
//dataGridView1.Columns[3].Visible = false;
//dataGridView1.Columns[2].Visible = false;
//dataGridView1.Columns[1].Visible = false;
//dataGridView1.Columns[0].Visible = false;
dataGridView1.DataSource = dt;
}
else
{
dataGridView1.DataSource = null;ath.GetFileName
//string path = // Application.StartupPath + @"\MyExcel.xlsx"; /
}
odr.Close();

string FileName2 = openFileDialog1.FileName; Server.MapPath("File/MyExcel.xlsx");
string connstr2 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName2;
connstr2 += ";Extended Properties=Excel 12.0;";

string strSQL2 = "SELECT * FROM [Sheet2$]";
OleDbConnection con2 = new OleDbConnection(connstr2);
con2.Open();
OleDbCommand com2;
com2 = new OleDbCommand(strSQL2, con2);
OleDbDataReader odr2;
com2.Parameters.Clear();
odr2 = com2.ExecuteReader();
DataTable dt2 = new DataTable();
if (odr2.HasRows)
{
dt2.Load(odr2);
//dataGridView1.Columns[3].Visible = false;
//dataGridView1.Columns[2].Visible = false;
//dataGridView1.Columns[1].Visible = false;
//dataGridView1.Columns[0].Visible = false;
dataGridView2.DataSource = dt2;
}
else
{
dataGridView2.DataSource = null;
}
odr2.Close();
}
for (int X = 0; X <= dataGridView1.RowCount - 1; X++)
{

Proj_name = Convert.ToString(dataGridView1.Rows[X].Cells[0].Value);

Proj_name_Values.Add(Convert.ToString(Proj_name));
}
for (int X = 0; X <= dataGridView1.RowCount - 1; X++)
{

Duration = Convert.ToInt32(dataGridView1.Rows[X].Cells[1].Value);

Duration_Values.Add(Convert.ToInt32(Duration));
}

for (int X = 0; X <= dataGridView1.RowCount - 1; X++) {

Predecessor = Convert.ToString(dataGridView1.Rows[X].Cells[2].Value);

String[] Word = Predecessor.Split(' ');

Predecessor_Number.Add(Convert.ToString(Word.Length));

Predecessor_Values.Add(Convert.ToString(Predecessor));

Predecessor_Value_FindLF.Add(Convert.ToString(Predecessor));
}
}
Posted
Updated 10-Feb-14 0:37am
v2
Comments
OriginalGriff 10-Feb-14 4:54am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps an example would help?
Use the "Improve question" widget to edit your question and provide better information.
Real_Criffer 10-Feb-14 6:50am    
i already edit the question thx for the reply :)

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