title: epplus using LoadFromCollection with anonymous types
body: <p>I have a <code>IEnumerable&lt;object&gt;</code> dataSource which contains a collection anonymous types. The actual structure of the anonymous type won't be known at design time, so I'm trying to find a generic solution that can handle any anonymous type.</p>
  
  <p>How can I load them into epplus to create a spreadsheet? I have a worksheet called ws and I tried:</p>
  
  <pre><code>ws.Cells["A1"].LoadFromCollection(dataSource, true);
  </code></pre>
  
  <p>However when that runs it outputs all of the anonymous type's properties into a single cell:</p>
  
  <pre><code>{ Id = 10000, Title = This is a test }
  </code></pre>
  
  <p>I've tried passing in MemberInfo using:</p>
  
  <pre><code>var members = dataSource.First().GetType().GetMembers();
  ws.Cells["A1"].LoadFromCollection(this._dataSource, true,
      TableStyles.Medium1, BindingFlags.Public, members);
  </code></pre>
  
  <p>But that throws an exception:</p>
  
  <blockquote>
    <p>Supplied properties in parameter Properties must be of the same type as T</p>
  </blockquote>
  
  <p>Any suggestions on how I can create a spreadsheet using anonymous types in c#?</p>