Back to Devexpress

DataSourceImportOptions Class

officefileapi-devexpress-dot-spreadsheet-6cf084cb.md

latest3.6 KB
Original Source

DataSourceImportOptions Class

Allows you to specify data source fields to import.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public class DataSourceImportOptions :
    DataImportOptions
vb
Public Class DataSourceImportOptions
    Inherits DataImportOptions

Remarks

When calling the WorksheetExtensions.Import method, create the DataSourceImportOptions instance and use the DataSourceImportOptions.PropertyNames property to specify field names which should be imported form the data source.

Example

View Example

csharp
List<TestObject> list = new List<TestObject>();
list.Add(new TestObject(1, "1", true));
list.Add(new TestObject(2, "2", false));
worksheet.Import(list, 0, 0, new DataSourceImportOptions() { PropertyNames = new string[] { "BoolValue", "IntValue" } });
vb
Dim list As New List(Of TestObject)()
list.Add(New TestObject(1, "1", True))
list.Add(New TestObject(2, "2", False))
worksheet.Import(list, 0, 0, New DataSourceImportOptions() With {
    .PropertyNames = New String() { "BoolValue", "IntValue" }
})
csharp
class TestObject
{
    public TestObject(int intValue, string value, bool boolValue)
    {
        this.intValue = intValue;
        this.Value = value;
        this.BoolValue = boolValue;

    }
    public int intValue;
    private int privateValue { get { return 123; } }
    public int IntValue { get { return intValue + privateValue - 123; } }
    public string Value { get; set; }
    public bool BoolValue { get; set; }
    public int this[int index] { get { return index; } }
}
vb
Friend Class TestObject
    Public Sub New(ByVal intValue As Integer, ByVal value As String, ByVal boolValue As Boolean)
        Me.intValue_Renamed = intValue
        Me.Value = value
        Me.BoolValue = boolValue

    End Sub
    Public intValue_Renamed As Integer
    Private ReadOnly Property privateValue() As Integer
        Get
            Return 123
        End Get
    End Property
    Public ReadOnly Property IntValue() As Integer
        Get
            Return intValue_Renamed + privateValue - 123
        End Get
    End Property
    Public Property Value() As String
    Public Property BoolValue() As Boolean
    Default Public ReadOnly Property Item(ByVal index As Integer) As Integer
        Get
            Return index
        End Get
    End Property
End Class

Inheritance

Object DataImportOptions DataSourceImportOptions

See Also

DataSourceImportOptions Members

DevExpress.Spreadsheet Namespace