ListView and Spreadsheet problem

I  can loop through an sheet excel spreadsheet and add each cell value in a relevant public strings

The strings are:
Staff ID      
Staff Name      
Windows Auth      
In DPM      
In PT      
In CT
In AP
In CS.

I have a public Dictionary and lists in the class:

public Dictionary<string, List<String>> map = new Dictionary<string, List<String>>();

        List<string> StaffIDs = new List<string>();
        List<string> StaffNames = new List<string>();
        List<string> WinAuths = new List<string>();
        List<string> InDPMs = new List<string>();
        List<string> InPTs = new List<string>();
        List<string> InCTs = new List<string>();
        List<string> InAPs = new List<string>();
        List<string> InCSs = new List<string>();

I can then add each value to the lists:
StaffIDs.Add(StaffID);
                StaffNames.Add(StaffName);
                 WinAuths.Add(WinAuth);
                 InDPMs.Add(InDPM);
                 InPTs.Add(InPT);
                 InCTs.Add(InCT);
                 InAPs.Add(InAP);
                 InCSs.Add(InCS);

I can then add each list to the dictionary:
map.Add("Staff ID", StaffIDs);
                map.Add("StaffName", StaffNames);
                map.Add("WinAuth", WinAuths);
                map.Add("InDPM", InDPMs);
                map.Add("InPT", InPTs);
                map.Add("InCT", InCTs);
                map.Add("InAP", InAPs);
                map.Add("InCS", InCSs);
 
but I am having a two-fold problem:

Firstly I want to be able pass the values in the dictionary to a list view where the values are displayed in the correct columns (apologies for below being out of alignment)

for example I want it to show:
Staff ID      Staff Name      Windows Auth      In DPM      In PT      In CT      In AP      In CS -- list view colums
ASAMPLE      Andrew Sample      WIN\Sampa      1      1      1      1      0
ASAMPLE_1      Jane Sample      WIN\Sampjane      1      1      0      1      1
ASAMPLE_2      Jill Sample      WIN\Sampjill      1      1      0      0      1
ASAMPLE_3      Eric Sample      WIN\Sampe      1      1      0      0      0
ASAMPLE_4      John Sample      WIN\Sampjohn      1      1      1      0      0
ASAMPLE_5      Julia Sample      WIN\Sampjulia      1      0      1      0      0
ASAMPLE_6      Steven A Sample      WIN\Sampstevena      1      1      0      0      0
ASAMPLE_7      Mark Sample      WIN\Sampm      1      0      0      0      0
ASAMPLE_8      Frank Sample      WIN\Sampf      1      0      0      0      0
ASAMPLE_9      Alan Sample      WIN\Sampal      1      0      1      0      0
ASAMPLE_10      Victoria Sample      WIN\Sampv      1      0      1      0      0

My second problem is that I want to create a spreadsheet where it has sheets based on criteria (under columns called Staff ID and StaffName):
First sheet listing all staff with ID and name,

Then each subsequent sheet adding Staff with ID and name  where the flags=1.
so if only 4 staff members are listed under the In PT has the value 1 then the relevant sheet only lists those staff members.

I am going in circles.

Any help much appreciated.
Jake CarterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
Wouldn't it be simpler to just use a List of a single entity; e.g. -
using System;
using System.Collections.Generic;
using System.Linq;

namespace EE_Q29082999
{
    class Program
    {
        readonly static List<Member> staff = new List<Member>
        {
            new Member { ID = "ASAMPLE", Name = "Andrew Sample", WindowsAuth = "WIN\\Sampa", InDPM = 1, InPT = 1, InCT = 1, InAP = 1, InCS = 0 },
            new Member { ID = "ASAMPLE_1", Name = "Jane Sample", WindowsAuth = "WIN\\Sampjane", InDPM = 1, InPT = 1, InCT = 0, InAP = 1, InCS = 1 },
            new Member { ID = "ASAMPLE_2", Name = "Jill Sample", WindowsAuth = "WIN\\Sampjill", InDPM = 1, InPT = 1, InCT = 0, InAP = 0, InCS = 1 },
            new Member { ID = "ASAMPLE_3", Name = "Eric Sample", WindowsAuth = "WIN\\Sampe", InDPM = 1, InPT = 1, InCT = 0, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_4", Name = "John Sample", WindowsAuth = "WIN\\Sampjohn", InDPM = 1, InPT = 1, InCT = 1, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_5", Name = "Julia Sample", WindowsAuth = "WIN\\Sampjulia", InDPM = 1, InPT = 0, InCT = 1, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_6", Name = "Steven A Sample", WindowsAuth = "WIN\\Sampstevena", InDPM = 1, InPT = 1, InCT = 0, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_7", Name = "Mark Sample", WindowsAuth = "WIN\\Sampm", InDPM = 1, InPT = 0, InCT = 0, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_8", Name = "Frank Sample", WindowsAuth = "WIN\\Sampf", InDPM = 1, InPT = 0, InCT = 0, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_9", Name = "Alan Sample", WindowsAuth = "WIN\\Sampal", InDPM = 1, InPT = 0, InCT = 1, InAP = 0, InCS = 0 },
            new Member { ID = "ASAMPLE_10", Name = "Victoria Sample", WindowsAuth = "WIN\\Sampv", InDPM = 1, InPT = 0, InCT = 1, InAP = 0, InCS = 0 }
        };

        static void Main(string[] args)
        {
            var sheet1 = (from member in staff
                          where new[] { "3", "6", "8" }.Any(x => member.ID.IndexOf(x, StringComparison.OrdinalIgnoreCase) > -1) ||
                          new[] { "Alan", "Andrew" }.Any(x => member.Name.IndexOf(x, StringComparison.OrdinalIgnoreCase) > -1)
                          select member);

            foreach (var member in sheet1)
            {
                Console.WriteLine(member);
            }
            Console.ReadLine();
        }
    }

    class Member
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string WindowsAuth { get; set; }
        public int InDPM { get; set; }
        public int InPT { get; set; }
        public int InCT { get; set; }
        public int InAP { get; set; }
        public int InCS { get; set; }

        public override string ToString()
        {
            return $"{{ {string.Join(", ", (from property in this.GetType().GetProperties() select $"{property.Name}: {property.GetValue(this, null)}"))} }}";
        }
    }
}

Open in new window

Which produces the following output -Capture.PNG
-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jake CarterAuthor Commented:
Apologies for the delay in replying.

I am using openfile dialog to find the spreadsheet and list needs to be populated blind as I will  not know  what they list.

Would the above allow that?
0
it_saigeDeveloperCommented:
So long as you can parse the spreadsheet, it should work fine.  Ofcourse, if your spreadsheet can change, then it may make more sense to load the spreadsheet into a datatable and then manipulate your data from there.

-saige-
0
Seth SimmonsSr. Systems AdministratorCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- it_saige (https:#a42463588)
-- it_saige (https:#a42469120)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

seth2740
Experts-Exchange Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.