如何串联脚本组件中的字符串? [英] how to Concatenate Strings in a Script Component?
问题描述
我的数据来自Excel电子表格,如下所示:
id ...发票
1 ........ a
1 ........ b
2 ........ c
3 ........ d
3 ........ e
3 ........ f
我想要一个看起来像这样的输出:
id .....发票
1 ........ a,b
2 ........ c
3 ........ d,e,f
我什至不确定我是否应该在查看每一行的子例程或查看整个缓冲区的子例程中尝试执行此操作.
感谢您的帮助或想法...
这完全取决于您如何接收数据.就个人而言,我将创建一个结构来保存每个发票状态,然后我将保存一个发票清单.然后,您可以使用GroupBy扩展名,就像这样
结构发票 { 公共 int id { get ; 设置; } 公共 字符串发票{ get ; 设置; } }
列表<发票>发票= 新列表< invoice>(); var groupedInvoices = invoices.GroupBy(i = > i.id);
希望对您有帮助
您好,
请点击链接.
只需更改Excel工作表的逻辑即可.
http://sqlyoga.com/2009/02/sql-server-get- comma-separated-list.html [ ^ ]
希望对您有帮助
谢谢
sanjeev
您可以使用具有多个值的词典 [ ^ ],添加到以下字典中处理行的方法
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...
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
struct invoice { public int id { get; set; } public string invoice { get; set; } }
List<invoice> invoices = new List<invoice>(); var groupedInvoices = invoices.GroupBy(i => i.id);
hope this helps
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
You could use a dictionary with multiple values[^], add to the dictionary in the method that processes a row
这篇关于如何串联脚本组件中的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!