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

In summary, the programmer wants to insert a matrix into another matrix, but does not know how to do it.
  • #1
sweetjones
44
0
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.

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!
 
Technology news on Phys.org
  • #2
Hi

my question is if there are any other free flex-paced similar online courses to Freecodecamp that give out a certification at the end of the course. I've been using FreeCodeCamp (www.freecodecamp.com) for a few weeks now. I love it. My question is if there are any other similar online free flex-paced computer programming classes that give out a certification at the end of the course. Thank you.
 
  • #3
I have a large C program running under Qnx7. It does a lot of stuff: TCP, terminal and file IO, Qnx messaging, etc., but none of which is relevant to my question.

Been chasing down a bug in the C library read() function which intermittently returns bad data with no error indication (a 2nd read from the same file offset usually returns the correct data). To try to track it down I trap and pass all calls to the C lib read() through my own identically prototyped read_wedge() function, which fills the passed buffer with repeated calls to read() of some maximum number of bytes. If this max value is 16 or less, the program runs fine for days. At 32 if failed after 20 hours of pounding. At 256 it fails in relatively short order. The larger this number, the more likely read() is to fail it seems. I've learned over the years that blaming the OS is not conducive to finding bugs. But, and this is my question, this has to be the OS, right? (I'm thinking either interrupts or caching.)
 
  • #4
Hi at all!

I need to insert a matrix in another bigger one using Boost library. An example:
I have a matrix A (3x3) and i want to insert it into an identity matrix B (4x4) in this way

matrix_block.jpg


This is my code:
C++:
boost::numeric::ublas::matrix<double> A(3,3);
boost::numeric::ublas::identity_matrix<double> B(4,4);

for (unsigned int i = 1; i < B.size1(); ++i)
{
    for (unsigned int j = 1; j < B.size2(); ++j)
    {
        B(i, j) = A(i - 1, j - 1);
    }
}

Is there a better way to do this using Boost library?

Thanks!
 

1. How do I compare multiple rows between two worksheets in C#?

In order to compare multiple rows between two worksheets in C#, you can use a loop. First, you will need to access the rows in each worksheet using a for loop. Then, you can use conditional statements to compare the values in each row.

2. What is the benefit of using a loop to compare rows in C#?

Using a loop allows for efficient and automated comparison of multiple rows between two worksheets. It saves time and reduces the likelihood of human error.

3. Can I compare specific rows between two worksheets in C#?

Yes, you can compare specific rows between two worksheets in C# by specifying the row numbers in your loop. This allows for targeted comparison and analysis of specific data.

4. How can I determine if the values in two rows are equal in C#?

You can use an if statement with the "==" operator to compare the values in two rows and determine if they are equal. If they are equal, the code within the if statement will be executed.

5. What happens if the rows being compared have different numbers of columns?

If the rows being compared have different numbers of columns, you may encounter errors or unexpected results. It is important to ensure that the rows being compared have the same number of columns, or to handle any discrepancies in your code.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
18
Views
5K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
Replies
15
Views
2K
Back
Top