E.g. If the input is { “1200,51.5”, “1206,5”, “1265,1”, “1206,8”, “1200,20.5” }
then
51.5 will go under Regular at C15
5 will go under Training at D15
1 will go under OT / CTO at E15
8 will go under Training at D16 ( As we have already filled at D15 above )
20.5 will go under Regular at C16 ( As we have already filled at C15 above )
Here 1200 Code belongs to the Regular Column
1206 Code belongs to the Training Column
12065 Code belongs to the OT / CTO Column
Like that, there is a Code for each column
The template format is fixed.
Excel after filling in data will look like the below:
I may get or not get 1200, I mean
If I am getting 1200 then 51.5 the value will be in the Regular Column, same for all.
I may get any code( like 1200), for each Column we have different code value.
you are a Gem, Superb.
One last doubt, Can we assign multiple codes for Single Column, I mean Can I assign 1200,1300,1250 all these three codes to the Regular column ( Column C in this case) or do I have to write the switch case three times?
Similarly, for other columns also like Code 1201,1401,1562 and 1587 for the Training Column.
If you want to use switch…then you need to add as different cases but ehat to do inside case will be same across the similr cases
Else we can use if condition where we can give multiple conditions like {"1234,"1200","1341"}.Contains(currentItem.Split({","},Stringsplitoptions.None)(1)) which will check for all the conditions at one and we cna use on then side the required write cell…and in else another condition for other column
Above code was very well explained.
Please do some small modification according to your requirement in the above code.
1- Since you required to updated in 3 columns C, D and E then create 3 counter variable out of foreach loop with default value associated with each columns. eg x=15, y=15 and z=15.
2- Move counter increment code inside your case block and increment counter variable associated to column C or D or E. so than next time only increment will be happen in same column position.