The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

IDataSourceColumnTypeDetector Interface

Provides the capability to identify the name and type of each column in a data source created from a cell range.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

public interface IDataSourceColumnTypeDetector
Public Interface IDataSourceColumnTypeDetector
public interface IDataSourceColumnTypeDetector
Public Interface IDataSourceColumnTypeDetector

Remarks

To specify column names and types using your own custom specifics, implement a class with the IDataSourceColumnTypeDetector interface and assign an instance of this class to the RangeDataSourceOptions.DataSourceColumnTypeDetector property of the options object passed to the Range.GetDataSource or the WorksheetDataBindingCollection.CreateDataSource method.

Examples

class MyColumnDetector : IDataSourceColumnTypeDetector {
    public string GetColumnName(int index, int offset, Range range) {
        if (offset > 3) return String.Format("Column{0}", index);
        string[] names = { "City", "Year", "Month", "Temperature" };
        return names[index];
    }

    public Type GetColumnType(int index, int offset, Range range) {
        Type defaultType = typeof(string);
        CellValue value = range[0, offset].Value;
        if (value.IsText) return typeof(string);
        if (value.IsBoolean) return typeof(bool);
        if (value.IsDateTime) return typeof(DateTime);
        if (value.IsNumeric) return typeof(double);
        return defaultType;
    }
}
See Also