Shawn Weisfeld

I find when I talk to myself nobody listens. - Shawn Weisfeld
posts - 364, comments - 174, trackbacks - 34

My Links

News


Shawn Weisfeld's Facebook profile

The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.

Archives

Post Categories

March 2012 Entries

Display a list of data as a set of columns not rows

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...

posted @ Thursday, March 22, 2012 9:14 AM | Feedback (0) |

Convert flattened data in Excel to a hierarchal XML File

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$]"; ...

posted @ Saturday, March 17, 2012 3:01 PM | Feedback (0) |

Powered by: