FAQ/inserting-ascii-or-unicode-characters.md
... ...
@@ -0,0 +1,75 @@
1
+#How do I insert non-alphanumeric characters in a standard character set into an Izenda Report?
2
+
3
+[[_TOC_]]
4
+
5
+#Question
6
+
7
+I'd like to insert some character into my report, but I'm having a hard time using an expression or value range.
8
+
9
+#Answer
10
+
11
+The easiest way for a user to enter a character which is not a standard letter or number is by using a custom format. This method requires more setup on the backend but is accessible to users with only a few clicks.
12
+
13
+In the example code below, we will convert a boolean True to a unicode tickmark and a boolean False to a blank space.
14
+
15
+```csharp
16
+AdHocSettings.Formats.Add("Check", new BoolToCheckFormat());
17
+
18
+
19
+[Serializable]
20
+public class BoolToCheckFormatter : IFormatter
21
+{
22
+ public Type GetOutputDataType(DataTable table, int columnNumber, ReportOutputOptions reportOutputOptions, Field field)
23
+ {
24
+ return typeof(string);
25
+ }
26
+
27
+ public object Format(DataTable table, int rowNumber, int columnNumber, Field field, DataTable originalTable, Field nameField)
28
+ {
29
+ object value = table.Rows[rowNumber][columnNumber];
30
+ if (value == null || Convert.IsDBNull(value))
31
+ return null;
32
+
33
+ if (value as bool? == true)
34
+ return "&#10004";
35
+ return "✘";
36
+ }
37
+}
38
+
39
+public class BoolToCheckFormat : IFormat
40
+{
41
+ private SqlTypeGroupCollection allowedTypeGroups = new SqlTypeGroupCollection();
42
+ public SqlTypeGroupCollection AllowedTypeGroups
43
+ {
44
+ get { return allowedTypeGroups; }
45
+ }
46
+
47
+ public SqlTypeGroupCollection DisallowedTypeGroups
48
+ {
49
+ get { return null; }
50
+ }
51
+
52
+ public string Name { get { return "Check"; } }
53
+
54
+ public SqlTypeGroup DefaultFor
55
+ {
56
+ get { return SqlTypeGroup.None; }
57
+ }
58
+
59
+ public bool Visible
60
+ {
61
+ get { return true; }
62
+ }
63
+
64
+ public IFormatter[] CreateFormatters()
65
+ {
66
+ return new IFormatter[] { new BoolToCheckFormatter() };
67
+ }
68
+
69
+ public BoolToCheckFormat()
70
+ {
71
+ allowedTypeGroups.Add(SqlTypeGroup.Binary);
72
+ allowedTypeGroups.Add(SqlTypeGroup.Numeric);
73
+ }
74
+}
75
+```
... ...
\ No newline at end of file