Spread for ASP.NET 11 Product Documentation
Formatter Field
Example 


FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > SheetStyleProperty Class : Formatter Field
Represents the Formatter property (index of 5) for the formatter of the sheet style.
Syntax
'Declaration
 
Public Shared ReadOnly Formatter As SheetStyleProperty
'Usage
 
Dim value As SheetStyleProperty
 
value = SheetStyleProperty.Formatter
public static readonly SheetStyleProperty Formatter
Example
<Serializable()> 
public class myf : FarPoint.Web.Spread.Renderer.IFormatter
{
    public string Format(object o) 
{
//int ret = o;
    switch (Convert.ToInt32(o))
{
    case 1:
    return "Test1";
    case 2:
    return "Test2";
    case 3:
    return "Test3";
}
return o.ToString();
}

    public object Parse(string s) 
{
    switch (s)
{
    case "Test1":
    return 1;
    case "Test2":
    return 2;
    case "Test3":
    return 3;
}
return s;
}
}

if (IsPostBack)
    {
        return;
    }
    DataTable dt = new DataTable();
    DataRow dr;
    dt.Columns.Add("Test");
    dr = dt.NewRow();
    dr[0] = 1;
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = 2;
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = 3;
    dt.Rows.Add(dr);
    FpSpread1.Sheets[0].DataSource = dt;
    FarPoint.Web.Spread.StyleInfo si = new FarPoint.Web.Spread.StyleInfo("DataAreaDefault");
    si.Formatter = new myf();
    FpSpread1.ActiveSheetView.DefaultStyle = si;
    bool b;
    b = si.IsPropertySet(FarPoint.Web.Spread.SheetStyleProperty.Formatter);
    if (b)
    {
        Response.Write("The formatter has been set.");
    }
<Serializable()> 
Public Class myf
Implements FarPoint.Web.Spread.Renderer.IFormatter

Public Function Format(ByVal o As Object) As String Implements FarPoint.Web.Spread.Renderer.IFormatter.Format
Select Case o
Case 1
Return "Test1"
Case 2
Return "Test2"
Case 3
Return "Test3"
End Select
End Function

Public Function Parse(ByVal s As String) As Object Implements FarPoint.Web.Spread.Renderer.IFormatter.Parse
Select Case s
Case "Test1"
Return 1
Case "Test2"
Return 2
Case "Test3"
Return 3
End Select
End Function
End Class

If IsPostBack Then Return
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add("Test")
dr = dt.NewRow
dr.Item(0) = 1
dt.Rows.Add(dr)
dr = dt.NewRow
dr.Item(0) = 2
dt.Rows.Add(dr)
dr = dt.NewRow
dr.Item(0) = 3
dt.Rows.Add(dr)
FpSpread1.Sheets(0).DataSource = dt
Dim s As FarPoint.Web.Spread.SheetStyleProperty
Dim si As New FarPoint.Web.Spread.StyleInfo("DataAreaDefault")
si.Formatter = New myf
FpSpread1.ActiveSheetView.DefaultStyle = si
Dim b As Boolean
b = si.IsPropertySet(s.Formatter)
If b Then
Response.Write("The formatter has been set.")
End If
See Also

Reference

SheetStyleProperty Class
SheetStyleProperty Members