Typically when asked to display a list data, lets say customers, we create a first name column, last name column and then iterate over the rows to produce a table. Something like this: But recently I was asked to produce a pivot of this data, putting each customer in their own column instead of an individual row. After doing the obligatory internet searching I found no solution that I really liked. So I wrote my own… Lets start by creating our customer object:public class Customer
{
public int Id { get; set; }
public...
Ever had an excel file that looked like this? and need an xml file that looks like this? Converting takes 2 steps: Step 1: Read the excel file into objects in memory var products = new List<Product>();
using (var con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=data.xlsx;Extended Properties=\"Excel 8.0;HDR=YES;\""))
using (var cmd = con.CreateCommand())
{
con.Open();
cmd.CommandText = "SELECT * FROM [Sheet1$]";
...