# GrapeCity.Documents.Excel.DataImportOptions.ColumnsSelector

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Excel_DataImportOptions_ColumnsSelector_" data-uid="GrapeCity.Documents.Excel.DataImportOptions.ColumnsSelector*">ColumnsSelector Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Excel_DataImportOptions_ColumnsSelector_" data-uid="GrapeCity.Documents.Excel.DataImportOptions.ColumnsSelector*"></a>
<h4 id="GrapeCity_Documents_Excel_DataImportOptions_ColumnsSelector" data-uid="GrapeCity.Documents.Excel.DataImportOptions.ColumnsSelector">ColumnsSelector</h4>
<div class="markdown level1 summary"><p>Selects columns to import. The default behavior is to auto-generate all columns.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Func&lt;object, IEnumerable&gt; ColumnsSelector { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Property ColumnsSelector As Func(Of Object, IEnumerable)</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a>&gt;</td>
      <td><p>The delegate accepts the collection or <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.datatable">DataTable</a> to select columns.<br>
The delegate returns different types of values to describe selected columns:</p>
<ul><li>
Returns <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a> of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.datacolumn">DataColumn</a> 
to select columns for the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.datatable">DataTable</a>.
</li><li>
Returns <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a> of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>
to select columns by indexes for the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.datatable">DataTable</a>.
</li><li>
Returns <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a> of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>
to select columns by names for the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.data.datatable">DataTable</a>, 
dictionary or custom object. 
This option is not AOT-compatible for custom objects.
</li><li>
Returns <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a> of property getter <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.delegate">Delegate</a> 
(where the delegate type of each element is <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func&lt;T, TResult&gt;</a>,
<code>T</code> is the element type of collection, 
<code>TResult</code> is the property type) to select columns
with custom column getters.<br>
In this case, <a class="xref" href="GrapeCity.Documents.Excel.DataImportOptions.IncludeColumnsHeader.html#GrapeCity_Documents_Excel_DataImportOptions_IncludeColumnsHeader">IncludeColumnsHeader</a> must be <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.
Otherwise, an exception will be thrown. Because we don't know the column names.
</li><li>
Returns <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable&lt;T&gt;</a> of named property getter <span class="xref">(T1, T2)</span> 
(where <code>T1</code> is column name <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>,
<code>T2</code> is property getter <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.delegate">Delegate</a>;
The delegate type of each element is <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-2">Func&lt;T, TResult&gt;</a>,
<code>T</code> is the element type of collection, 
<code>TResult</code> is the property type) to select columns
with custom column names and custom column getters. <br>
In this case, <a class="xref" href="GrapeCity.Documents.Excel.DataImportOptions.IncludeColumnsHeader.html#GrapeCity_Documents_Excel_DataImportOptions_IncludeColumnsHeader">IncludeColumnsHeader</a> should be <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a>. 
Otherwise, the column names will be ignored.
</li></ul>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_Documents_Excel_DataImportOptions_ColumnsSelector_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>The default behavior is not AOT-compatible for custom objects.</p>
</div>
</div>
