c# - Generating a Tree Structure From Table -
i have excel document below
+-------+-------+-------+ | col1 | col2 | col3 | +-------+-------+-------+ | item1 | | | | | item2 | | | | item3 | | | | | item4 | | | item5 | | | item6 | | | | | item7 | | +-------+-------+-------+ in table;
item1 parent of item2, item3, item5
item3 parent of item4
item6 parent of item7
i want generate tree structure table couldn't figure out how do. how can using c#.
thanks
keep list of parents columns. parent first column tree root. when treat row, append item resecive parent. (it's error when there no such parent, foe example if item4 in column 3.) add added item list , remove lower items.
to illustrate:
current item col pnt parent list | | | | [root] | item1 | | | 1 0 [root, item1] | | item2 | | 2 1 [root, item1, item2] | | item3 | | 2 1 [root, item1, item3] | | | item4 | 3 2 [root, item1, item3, item4] | | item5 | | 2 1 [root, item1, item5] | item6 | | | 1 0 [root, item6] | | item7 | | 2 1 [root, item6, item7] the parent of current item list[pnt], index of parent element in list pnt = col - 1. added element last element in list.
Comments
Post a Comment