This project has moved. For the latest updates, please go here.

Double foreach

Oct 17, 2014 at 12:14 AM
Hi I am new to ClosedXML

I have the following:
. worksheet.Cell ("A2") = Value Report.GetDato (Id);

This is correct, but from column D, I have a foreach, the result is similiar to the next.
one, two, three, four.

All this appears to me within the column D

With ClosedXML as I can get each result appears in a different column?

Like this:
D E F G
one two three four


Thank you very much.
Coordinator
Oct 17, 2014 at 12:22 AM
I have no clue what you're trying to say. Give a piece of code that reproduces the problem.
Oct 17, 2014 at 12:45 AM
Edited Oct 17, 2014 at 12:50 AM
This is the code:


List<ReportArgs > list = new List<ReportArgs >();
List<Persons> persons = DB.Persons.AsNoTracking().AsParallel().OrderBy(o => o.IdPerson).ToList();
var Cars= DB.PersonCars.AsNoTracking().ToList().AsReadOnly();
               foreach (var item in persons )
                {

                    ReportArgs report= new ReportArgs();

                   report.Name = item.Name;
                   report.SeconName = item.SeconName;
                   report.Age = item.Age;

                foreach (var itm in Cars.Where(x => x.IdPerson == item.Idperson).ToList())
                    {
                        report.Cars  += itm.MatriculaAsociada.ToString();

                    }

                    list .Add(report);
                }
I have the following:

worksheet.Cell ("A2") = Value Report.GetDato(Id);

Once the report is presented gives me the following result

COLUMN A, COLUMN B COLUMN C COLUMNA D
Michael Robert 26 cared caryellow, carblue

But I need it to appear like this:

COLUMN A, COLUMN B COLUMN C COLUMNA D COLUMN E COLUMNA F
Michael Robert 26 carred caryellow carblue

Thanks.
Coordinator
Oct 17, 2014 at 1:46 AM
Still no clue if there's a bug or not but it seems like you need to create the table yourself instead of passing that collection to a cell.
Oct 17, 2014 at 1:49 AM
Exactly need to pass the collection to a table because the displays into a single cell