Entity object to Excel Support

Dec 21, 2010 at 7:09 AM

During my holiday, i'll be looking into enabling Entity object to excel support.

What's going to happen:

  • There'll be methods that would take a TEntity type object
  • Use the entity object property as header
  • Write data recursively

Examle:

// example class
public class Orders
{
  public int ID {get;set;}
  public string Name {get;set;}
  public string Description {get;set;}
  public List<Item> Items {get;set;}
}

// example methods
var sheet = package.Workbook.Worksheets["Sheet1"];
var orders = new List<Orders>
{
 ID=1,
 Name="Fruits",
 Description="All sort of fruits", 
 new List<Item>
 {
  {ID=53, Name="Apple", Price=1.99m},
  {ID=54, Name="Banana", Price=2.99m}
 }
},
{
 ID=2,
 Name="Vegetables",
 Description="All sort of vegetables", 
 new List<Item>
 {
  {ID=84, Name="Lettuce", Price=1.99m},
  {ID=84, Name="Broccoli", Price=3.99m}
 }
}
sheet.Add(orders);