请教如何将datagridview里的每行数据(从一个excel中读出来的)存到list列表里面(list里面存放的是student的对象),部分代码如下:
string sql_select = " SELECT StudentID,StudentName,StudentBirthday,StudentAddress FROM [Sheet1$]";
GetDataFromExcel GD = new GetDataFromExcel();
DataTable dt = GD.getData("students.xlsx", sql_select).Tables[0];
dataGridView.DataSource = dt;
dataGridView.AllowUserToResizeColumns = true;
dataGridView.Font = new Font("Arial", 11);
Student stu = new Student();
List listStudent = new List();
foreach (DataGridViewRow rows in dataGridView.Rows )
{
Student stu = new Student(rows.Cells[0].Value.ToString(),
rows.Cells[1].Value.ToString(),
rows.Cells[2].Value.ToString(),
rows.Cells[3].Value.ToString());
listStudent.Add(stu);
}