title: Read data from combined Excel columns/rows using C#
body: <p>I'm trying to read data from an Excel document in C# using Microsofts COM Interop.</p>
  
  <p>So far, I'm able to load the document and read some data from it. However, I need to read data from two different columns and output these as json (for a jquery ajax call)</p>
  
  <p>I've made a quick prototype of how my Excel document is structured with the hope that it's a bit easier to explain ;-)</p>
  
  <p><img src="https://i.stack.imgur.com/vam5v.png" alt="enter image description here"></p>
  
  <p>The method I have is called <code>GetExcelDataByCategory(string categoryName)</code> where the categoryName parameter would be used to find which column to get the data from.</p>
  
  <p>So, i.e., if I'm making the call with "Category 2" as parameter, I need to get all the values in the C columns rows <strong>and</strong> the corresponding dates from the A column, so the output will look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/yAtM6.png" alt="enter image description here"></p>
  
  <p>Which then needs to be transformed/parsed into JSON.</p>
  
  <p>I've searched high and low on how to achieve this, but with no luck so far :-( I'm aware that I can use the get_Range() method to select a range, but it seems you need to explicitly tell the method which row and which column to get the data from. I.e.: get_Range("A1, C1")</p>
  
  <p>This is my first experience with reading data from an Excel document, so I guess there's a lot to learn ;-) Is there a way to get the output on my second image?</p>
  
  <p>Any help/hint is greatly appreciated! :-)</p>
  
  <p>Thanks in advance.</p>
  
  <p>All the best,</p>
  
  <p>Bo</p>