Loops to compare many rows between 2 worksheets in C#?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Loops to compare many rows between 2 worksheets in C#?

  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Loops to compare many rows between 2 worksheets in C#?

    Hello All,

    I took it upon myself to create a tool for my job that xref 2 excel worksheets on 2 different workbooks. Customers send us parts and they're wanting the leadtimes for them. We have a weekly report that has all part numbers with their leadtimes. My goal is to create a GUI in C# that my team can copy & paste the customer's requested part numbers into a control, then click a button that generates a new excel file with those pasted parts in the 1st column. While simultaneously have the weekly report opened in the background. Compare each row of customer parts with the weekly report and if there's a match, provide it's respective leadtime number in column B. The only thing I have figured out so far is to open the workbooks and name the worksheet.(whoopty doo)

    My issues so far:

    1. What control to use in my windows form that can hold a varying number of part numbers? I know a rich textbox has limits. The number of parts a customer sends us vary. One could send in 50 part numbers, and someone else could send 2000 parts. Would a DataGridView work?

    2. What type of loop should be used to compare 2 columns on 2 different worksheets, and provide their respective row of info?


    In theory this seemed pretty straight forward and not that difficult, but it seems like working with Interop.Excel gets pretty messy. Looks like I've dug myself a deep hole. I would really appreciate any input that you may have.

    Thanks in advance!!!

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,451

    Re: Loops to compare many rows between 2 worksheets in C#?

    Interop.Excel can be frustrating to use. You might want to look into using Excel as a database.

    http://www.c-sharpcorner.com/UploadF...ssExcelDb.aspx

    I would look into this first, then come back and ask your questions about that. It would be much easier to use SELECTS to find what you need.

  3. #3
    Join Date
    Jun 2012
    Posts
    2

    Re: Loops to compare many rows between 2 worksheets in C#?

    Quote Originally Posted by sotoasty View Post
    Interop.Excel can be frustrating to use. You might want to look into using Excel as a database.

    http://www.c-sharpcorner.com/UploadF...ssExcelDb.aspx

    I would look into this first, then come back and ask your questions about that. It would be much easier to use SELECTS to find what you need.
    Thanks a lot! I will look into this solution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center