-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyColumnDetector.cs
29 lines (27 loc) · 960 Bytes
/
MyColumnDetector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using DevExpress.Spreadsheet;
using System;
using System.Linq;
namespace RangeDataSourceForSnap
{
#region #MyColumnDetector
class MyColumnDetector : IDataSourceColumnTypeDetector
{
public string GetColumnName(int index, int offset, CellRange 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, CellRange 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;
}
}
#endregion #MyColumnDetector
}