Any .Net function or linq request to discard data

Is there any .net library for excel output? I am currently using the LinqToExcel environment to read data from spreadsheets, so I'm not sure if there are dynamic linq queries available to run univot. Thanks for any suggestions. BTW, I am looking for a solution that can handle multiple columns.

Example Source Table

Product Location Customer1 Customer2 Customer3 AX 10 20 100 

Destinaton table

 Product Location Customer Demand AX Customer1 10 AX Customer2 20 AX Customer3 100 
+4
source share
1 answer

Try something like this:

 var customer1 = from c in excel.Worksheet() select new { Product = c["Product"], Location = c["Location"], Customer = "Customer1", Demand = c["Customer1"], }; var customer2 = from c in excel.Worksheet() select new { Product = c["Product"], Location = c["Location"], Customer = "Customer2", Demand = c["Customer2"], }; var customer3 = from c in excel.Worksheet() select new { Product = c["Product"], Location = c["Location"], Customer = "Customer3", Demand = c["Customer3"], }; var customers = customer1.Union(customer2).Union(customer3); 

Based on your comment, try the following:

 var columns = 4; /* how many columns to unpivot */ var customers = from n in Enumerable.Range(2, columns) from c in excel.Worksheet() select new { Product = c["Product"].Value, Location = c["Location"].Value, Column = n.ToString(), Demand = c[n].Value, }; 
+5
source

All Articles