# Parsing Formulas in Custom XML Deserialization

Learn how to parse formulas in custom XML deserialization and handle cross-sheet references in Spread with our comprehensive guide.

## Content



With the implementation of cross-sheet references in Spread, formulas can contain references to other sheets. If such formulas are loaded from a file, the Spread component must load sheets and formulas in a specific sequence for the cross-sheet references to work. The parsing of formulas loaded from a file must be delayed until all the sheets in the workbook have been loaded. The **Open** methods in **FpSpread** handle this automatically, loading the XML and parsing in the correct order.

If you have created custom deserialization code, then you have to be careful. If your custom code loads individual sheets and adds them to a workbook, then you will need to add code to parse the formulas after the sheet has been added to the workbook. This can be done with the [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.LoadFormulas.html) method, available in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) class. This method is implemented in the [DefaultSheetDataModel](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Model.DefaultSheetDataModel.html) and [SheetView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.html) classes as well as the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) class. Using the [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.LoadFormulas.html) method at the sheet level calls the method on all the data models for a particular sheet; using the [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.LoadFormulas.html) method at the **FpSpread** level calls the method on all the sheets.

For example, the following code (in Visual Basic):

`FpSpread.Sheets.Add(FarPoint.Win.Serializer.LoadObject(GetType (FarPoint.Win.Spread.SheetView), "C:\SavedSheet.xml", "RootNode"))`

should be changed to:

`FpSpread.Sheets.Add(FarPoint.Win.Serializer.LoadObject(GetType (FarPoint.Win.Spread.SheetView), "C:\SavedSheet.xml", "RootNode")) FpSpread.LoadFormulas()`

This code should be called after the code that loads the sheet and adds it to the workbook.

For more details, refer to these methods:

*   FpSpread [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.LoadFormulas.html) method
*   SheetView [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.LoadFormulas.html) method
*   DefaultSheetDataModel [LoadFormulas](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Model.DefaultSheetDataModel.LoadFormulas.html) method
*   DefaultSheetDataModel [ParseFormula](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Model.DefaultSheetDataModel.ParseFormula.html) method

For more information about formulas and cross-sheet referencing, refer to the [Formula Reference](https://developer.mescius.com/spreadnet/docs/latest/online-formula/overview.html).

## See Also

[Implementing a Serializer Class](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-usefiles/spwin-serializeops/spwin-save-serializer)