如何串联脚本组件中的字符串? [英] how to Concatenate Strings in a Script Component?

查看:95
本文介绍了如何串联脚本组件中的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定该怎么做.我以为可以在脚本组件中完成此操作,但是经过一天的试验,我没有更进一步.我还想知道是否可以使用其他组件.



我的数据来自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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆