FAQ/Questions/Add-Formatting-Options.md
... ...
@@ -109,6 +109,24 @@ _**Note:** You can use this as a template and any other format that requires a b
109 109
}
110 110
```
111 111
112
+You must also adhere to the following two rules:
113
+
114
+1) Excel-exportable custom datetime formats must be added to AdHocSettings.Formats as an instance of the SimpleFormat class (or as an instance of custom format class), but NOT as just a string with pattern.
115
+
116
+2) The same string pattern of custom datetime format must be passed to the format class constructor in "formatString" parameter, and to AdHocSettings.Formats.Add in "key" parameter.
117
+
118
+Please see this sample code:
119
+
120
+```
121
+
122
+ DateTimeFormatInfo fmt = (new CultureInfo("en-gb")).DateTimeFormat;
123
+ string formatStr = "{0:" + fmt.ShortDatePattern + "}";
124
+ string formatDesc = fmt.ShortDatePattern + "(ex." + DateTime.Today.ToString(fmt.ShortDatePattern) + ")";
125
+ SimpleFormat formatObj = new SimpleFormat(formatDesc, formatStr, new SqlTypeGroup[] { SqlTypeGroup.DateTime });
126
+ AdHocSettings.Formats.Add(formatStr, formatObj);
127
+
128
+```
129
+
112 130
113 131
###Results
114 132