Hi,
My code is here:
private void btnExcel_Click(object sender, EventArgs e)
{
// create excel sheet
Worksheet.Cells[1, 1] = "Name";
Worksheet.Cells[1, 2] = "Date";
Worksheet.Cells[1, 3] = "Task Name";
Worksheet.Cells[1, 4] = "Time";
for(int i=0; i<cmbName.Items.Count; i++)
{
//Connection to the database and retriving data from the databse
if (datardr.HasRows)
{
int j = 1;
while (datardr.Read())
{
Worksheet.Cells[j + 1, 2] = datardr[0].ToString();
Worksheet.Cells[j + 1, 3] = datardr[1].ToString();
Worksheet.Cells[j + 1, 4] = datardr[2].ToString();
j = j + 1;
}
}
datardr.Close();
con.Close();
}
In cmbName (Combo box has 11 names).
My problem is:
I want to show data in the excel like the following:
Name | Date | Task Name | Time |
xyz | 11.07.2012 | sjhgg | 2 |
| 12.07.2012 | sgdfgfd | 3 |
| 13.07.2012 | sgdfgfd1 | 3 |
| 14.07.2012 | sgdfgfd2 | 4 |
| | | |
| | | |
| | | |
abc | 11.07.2012 | rfgdf | 5 |
| 12.07.2012 | fdhdfh | 6 |
| 13.07.2012 | dfhdfh | 7 |
| 14.07.2012 | fdhdh | 8 |
| | | |
I have problem in looping.
Thanks!!
Darma