# Using Serialization

Understand the difference between saving methods.

## Content



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](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.html) as opposed to the ones in the model namespace FarPoint.Win.Spread.Model.[SpreadSerializer](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Model.SpreadSerializer.html). The [SpreadSerializer](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Model.SpreadSerializer.html) is intended for saving and loading entire Spread component objects or text files from a sheet, while the [Serializer](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.html) 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.

*   [Implementing a Serializer Class](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-serializeops/spwin-save-serializer)
*   [Parsing Formulas in Custom XML Deserialization](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-serializeops/spwin-open-parseformulas)

The method to use for simply saving an object to a file is [SaveObject](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.SaveObject.html); the method for loading the object back from the file is [LoadObject](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.LoadObject.html). 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](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.SaveObject.html) with only the object, filename, and root element name arguments, and the overload for [LoadObject](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.LoadObject.html) with only the type, filename, and element name should work. The [SaveObject](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.SaveObject.html) 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](/spreadnet/api/latest/online-win/FarPoint.Win/FarPoint.Win.Serializer.CreateObjectInstanceAndDeserialize.html) 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

[File Operations](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles)

[Saving Data to a File](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-savefiles)

[Opening Existing Files](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-openfiles)