Spread Windows Forms 15.0
Spread Windows Forms 15.0 Product Documentation / Developer's Guide / File Operations / Using Serialization
In This Topic
    Using Serialization
    In This Topic

    In Spread, you can serialize objects in the spreadsheet or the entire spreadsheet component using several methods. Be sure you understand the difference between saving with the methods in FarPoint.Win.Serializer as opposed to the ones in the model namespace FarPoint.Win.Spread.Model.SpreadSerializer. The SpreadSerializer is intended for saving and loading entire Spread component objects or text files from a sheet, while the Serializer contains methods for saving and loading any serializable object using our XML serialization implementation. For more details on serializing and deserializing, refer to these tasks.

    The method to use for simply saving an object to a file is SaveObject; the method for loading the object back from the file is LoadObject. The methods are overloaded so you can save or load to a stream or use a particular XML serialization interface. For many purposes the overload for SaveObject with only the object, filename, and root element name arguments, and the overload for LoadObject with only the type, filename, and element name should work. The SaveObject method checks to see if the object is in the FarPoint Spread DLL or the FarPoint Win DLL, and if not, then it saves the assembly name in the XML node attributes and uses that name to load the assembly in the CreateObjectInstanceAndDeserialize method.

    Design-time serialization is complicated, and Spread uses several custom CodeDomSerializer objects to serialize at design time. Those serializers are coded to expect the FpSpread and the SheetView to be fields in the object being serialized, and if the object is instead returned by a property accessor, the code probably is not get generated correctly. For this reason exposing a property of type FpSpread or SheetView at design time is not recommended.

    See Also