Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am uncertain how to do this. I am thinking it could be done in a script component, but after a day of experimentation, I'm not getting any closer. I'd also like to know if there is another component I may be able to use for this.



I have data coming from an Excel Spreadsheet that looks like this:



id ...Invoice

1 ........ a

1 ........ b

2 ........ c

3 ........ d

3 ........ e

3 ........ f



I would like an output that looks like this:



id ..... Invoice

1 ........ a, b

2 ........ c

3 ........ d, e, f



I am not even sure if I should be trying to do this in the subroutine that looks at each row or the one that looks at the entire buffer.



Thanks for any help or ideas...
Posted

It would all depend on how you are receiving the data. Personally, I would create a struct to hold each invoice state, then I would hold a List of invoices. Then you could use the GroupBy extension, something like this

C#
struct invoice
        {
            public int id { get; set; }
            public string invoice { get; set; }
        }


C#
List<invoice> invoices = new List<invoice>();
var groupedInvoices = invoices.GroupBy(i => i.id);


hope this helps
 
Share this answer
 
Hello,

Follow the link.
just change the logic for excel sheet.


http://sqlyoga.com/2009/02/sql-server-get-comma-separated-list.html[^]

Hoping it will help you
thanks

sanjeev
 
Share this answer
 
You could use a dictionary with multiple values[^], add to the dictionary in the method that processes a row
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900