• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 48
  • Last Modified:

Help updating a ForLoop

I need help with this For Loop.  I should be writing more than one line.  I am building an Excel file.  The Hats.Count is more than one but I am only writing one line in the for loop.

for (row = 5; row - 5 < Hats.Count; row++)
            {
                ws.Cells[row, 1].Value = Hats[row - 5].data.Name

                foreach (var c in Hats[row - 5].columns)
                {
                    ws.Cells[row, c].Value = "X";
                    ws.Cells[row, c].Style.HorizontalAlignment = HorizontalAlignmentStyle.Center;
                    ws.Cells[row, c].Style.Font.Weight = ExcelFont.BoldWeight;
                }
            }

Open in new window

0
Crystal Rouse
Asked:
Crystal Rouse
  • 2
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
what do you get for each alert?
for (row = 5; row - 5 < Hats.Count; row++)
            {
                ws.Cells[row, 1].Value = Hats[row - 5].data.Name
alert(typeof Hats[row - 5]); //alert1
alert(typeof Hats[row - 5].columns); //alert2
alert(typeof Hats[row - 5].columns.length); //alert3
foreach (var c in Hats[row - 5].columns)

Open in new window

0
 
Julian HansenCommented:
What does your input data look like (Hats)?
What are you expecting to see in the output?
What are you seeing in the output?
0
 
Crystal RouseWeb Developer/Database AdminAuthor Commented:
My forloop is only returning one line where in the test case I'm using I should be getting 2 lines of data.
0
 
Julian HansenCommented:
What does your input data look like (Hats)?
0
 
Crystal RouseWeb Developer/Database AdminAuthor Commented:
I was able to figure it out using alerts.
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now