RT
希望给出一个代码框架

解决方案 »

  1.   

    只能给你思路:
    1、把excel的内能读取为DataTable(baidu,google下)
    2、在DataTable取到指定行,
    3.在DataGridView的绑定的DataTable中,加入指定行,并把它重新绑定给DataGridView。
      

  2.   

    下面是读取excel到dataset,然后获取dateset的某行的代码是ds.table[0].row[i],然后绑定到datagridview。public DataSet readExcelData(string sFile)
     {
      DataSet result = null;
      string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + sFile + ";" + "Extended Properties=Excel 8.0;";
      OleDbConnection conn = new OleDbConnection(strConn);
      try
      {
              conn.Open();
              string strExcel = "select * from [sheet1$]";
              OleDbDataAdapter myCommand = new OleDbDataAdapter(strExcel, strConn);
              result = new DataSet();
              myCommand.Fill(ds, "table1");
      }
      finally
      {
       conn.Close();
      }
      return result;
     }
      

  3.   

    LS 获取后如何绑定到datagridview的具体的一列
      

  4.   

    i行绑定到datagridview,代码如下。
    Tables["t1"]是excel读入的表。t0是新建表,用来绑定datagridview的。
    dr["字段名"]是把t1表某行写到t0表的列的字段名
                    for (int i = 0; i < ds.Tables["t1"].Columns.Count; i++)
                    {
                        DataRow dr = ds.Tables["t0"].NewRow();
                        dr["csv字段"] = ds.Tables["t1"].Columns[i].ColumnName.ToString();
                        ds.Tables["t0"].Rows.Add(dr);
                    }