Spread ASP.NET 15
FarPoint.Web.Spread Assembly / FarPoint.Web.Spread Namespace / SheetStyleProperty Class / Formatter Field

In This Topic
    Formatter Field
    In This Topic
    Represents the Formatter property (index of 5) for the formatter of the sheet style.
    Public Shared ReadOnly Formatter As SheetStyleProperty
    Dim value As SheetStyleProperty
    value = SheetStyleProperty.Formatter
    public static readonly SheetStyleProperty Formatter
    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)
        DataTable dt = new DataTable();
        DataRow dr;
        dr = dt.NewRow();
        dr[0] = 1;
        dr = dt.NewRow();
        dr[0] = 2;
        dr = dt.NewRow();
        dr[0] = 3;
        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.");
    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
    dr = dt.NewRow
    dr.Item(0) = 1
    dr = dt.NewRow
    dr.Item(0) = 2
    dr = dt.NewRow
    dr.Item(0) = 3
    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