title: I want to generate excel report for multiple employee
body: <p>I want to generate employee report for month wise. But i can't do this. I just try to do this. But it returns only last employee record. </p>
  
  <p>Am using list box and select multiple employee to generate report. But i can't do it.</p>
  
  <p>My partial cod is here..</p>
  
  <pre><code>DataSet4TableAdapters.sp_getalltimesheetTableAdapter TA1 = new DataSet4TableAdapters.sp_getalltimesheetTableAdapter();
  DataSet4.sp_getalltimesheetDataTable DS1 = TA1.GetData();
  foreach (DataRow dr in DS1.Rows)
  {
      string name = Convert.ToString(dr["Employee_ID"]) + "-" + Convert.ToString(dr["Employee_Name"]);
      for (int i = 0; i &lt; lbxempname.Items.Count; i++ )
      {
          if (lbxempname.Items[i].Selected)
          {
              string id = lbxempname.Items[i].Text;
              if (name == id)
              {
                  string expression = "Employee_Id='" + name.Substring(0,8) + "'and punchDate &gt;=#" + txtstartdate.Text + "# and PunchDate &lt;=#" + txtenddate.Text + "# ";
                  DataSet4TableAdapters.sp_getalltimesheetTableAdapter TA = new DataSet4TableAdapters.sp_getalltimesheetTableAdapter();
                  DataSet4.sp_getalltimesheetDataTable DS = TA.GetData();
                  if (DS.Rows.Count == 0)
                  {
                      ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "&lt;script language='javascript'&gt;alert('No records found');&lt;/script&gt;", false);
                  }
                  else
                  {
                      DataView dataview = DS1.DefaultView;
                      dataview.RowFilter = expression;
                      Session["TaskTable"] = dataview;
                      grdvw = new GridView();
                      grdvw.DataSource = Session["TaskTable"];
                      grdvw.DataBind();
                      dt = new DataTable();
                      dt.Columns.Add("EmployeeId");
                      dt.Columns.Add("EmployeeName");
                      dt.Columns.Add("Department");
                      dt.Columns.Add("Date");
                      dt.Columns.Add("Day");
                      dt.Columns.Add("Intime");
                      dt.Columns.Add("Outtime");
                      dt.Columns.Add("Late_After");
                      dt.Columns.Add("Early_Before");
                      dt.Columns.Add("Remarks");
                      foreach (GridViewRow oItem in grdvw.Rows)
                      {
                          DataRow dr1 = dt.NewRow();
                          string empid = oItem.Cells[0].Text;
                          string empname = oItem.Cells[1].Text;
                          string dept = oItem.Cells[2].Text;
                          string PunchDate = oItem.Cells[3].Text;
                          string Day = oItem.Cells[4].Text;
                          string intime = oItem.Cells[5].Text;
                          string outtime = oItem.Cells[6].Text;
  
                          groupdetails(empid, empname, PunchDate, dept, intime, outtime);
                          if (intime == "" || outtime == "")
                          {
                              remark = "A";
                          }
                          else
                          {
                              remark = "P";
                          }
                          dr1["EmployeeId"] = Convert.ToString(empid);
                          dr1["EmployeeName"] = Convert.ToString(empname);
                          dr1["Department"] = Convert.ToString(dept);
                          dr1["Date"] = Convert.ToString(PunchDate);
                          dr1["Day"] = Convert.ToString(Day);
                          dr1["Intime"] = Convert.ToString(intime);
                          dr1["Outtime"] = Convert.ToString(outtime);
                          dr1["Late_After"] = Convert.ToString(Session["late"].ToString());
                          dr1["Early_Before"] = Convert.ToString(Session["early"].ToString());
                          dr1["Remarks"] = Convert.ToString(remark);
                          dt.Rows.Add(dr1);
                          ViewState["new"] = dt;
  
                      }
                  }
              }
  
          }
  
      }
  }
  grdvw.DataSource = ViewState["new"];
  grdvw.DataBind();
  System.IO.StringWriter stringwriter = new StringWriter();
  HtmlTextWriter htmlwriter = new HtmlTextWriter(stringwriter);
  grdvw.RenderControl(htmlwriter);
  Response.Write(stringwriter.ToString());
  Response.End();
  </code></pre>
  
  <p>it return the output of last selected employee. But i want all selected employee record from listbox
  please help me...
  My output is like this...</p>
  
  <pre><code>   EmployeeId   EmployeeName    Department  Date            Day     Intime      Outtime     Late_After  Early_Before    Remarks
     00626243         HariharanJ  SBS IT      01-04-2012  Wednesday   06:40:00    15:00:00    00:00        00:00          P
     00626243         HariharanJ  SBS IT      01-03-2012  Tuesday     00:00:00    14:40:00    00:00        00:05          P
     00626243         HariharanJ  SBS IT      01-05-2012  Thursday    07:00:00    14:35:00    00:20        00:10          P
  </code></pre>
  
  <p>The above report is listbox last selected employee. I want this kind of report for all employee with small break with above head..</p>