/
MyConverter.cs
29 lines (27 loc) · 1.16 KB
/
MyConverter.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 DevExpress.Spreadsheet.Export;
using System;
namespace ExportToDataTableWorkbookExample {
#region #MyConverter
class MyConverter : ICellValueToColumnTypeConverter {
public bool SkipErrorValues { get; set; }
public CellValue EmptyCellValue { get; set; }
public ConversionResult Convert(Cell readOnlyCell, CellValue cellValue, Type dataColumnType, out object result) {
result = DBNull.Value;
ConversionResult converted = ConversionResult.Success;
if (cellValue.IsEmpty) {
result = EmptyCellValue;
return converted;
}
if (cellValue.IsError) {
// You can return an error, subsequently the exporter throws an exception if the CellValueConversionError event is unhandled.
//return SkipErrorValues ? ConversionResult.Success : ConversionResult.Error;
result = "N/A";
return ConversionResult.Success;
}
result = String.Format("{0:MMMM-yyyy}", cellValue.DateTimeValue);
return converted;
}
}
#endregion #MyConverter
}