TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
darma teja
NA
496
337.4k
How to loop after loop in excel
Nov 21 2012 12:24 PM
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
Reply
Answers (
5
)
Convert parts of the string into lower case
C# O-O Style