# Saving Spreadsheet Data to Simple XML

Learn how to save spreadsheet data to a simple XML format for further processing and structured storage.

## Content

You can save the data from a sheet to an XML file or stream if you need to process the data further and want the data in a structured format. This does not save the entire spreadsheet nor does it save the formatting information or presentation-related settings. Only the values in the cells are saved to XML. The header cells are not saved out to XML; only the data area cells.
To save the data to XML, use the [SaveXml](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SaveXml.html) methods of the SheetView class.
You can save the data to one file (or stream) and the XML schema to another file (or stream). An example output is shown below. The top level (or root) element is the sheet (SheetName) and within the sheet element are row elements (Row1, Row2, and so on) and within each row are the column elements (Column1, Column2, and so on) and within each column element is the data. The sheet element uses the name of the sheet. The rows are all generic rows and are not given unique names. The columns are each given a unique name and columns without data are ignored.
The [SaveXml](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SaveXml.html) method only saves the data for an individual sheet, not for an entire hierarchy that consists of several sheets.
This method only saves the data. For cell type data, see [Understanding How Cell Types Display and Format Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-datacelltextvalue).

## Using Code

Use the [SaveXml](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SaveXml.html) method to save data to an XML file.

## Example

This example saves the data for a sheet named "EastCoastSales" to an XML file and the schema to another file.

```csharp
fpSpread1.ActiveSheet.SaveXml("C:\\testfiles\\FPSpread-SheetToXML2.xml", "C:\\testfiles\\FPSpread-SchemaForXML2.xml");
```

```vbnet
fpSpread1.ActiveSheet.SaveXml("C:\testfiles\FPSpread-SheetToXML2.xml", "C:\testfiles\FPSpread-SchemaForXML2.xml")
```

This gives the following result:

```xml
<EastCoastSales>
   <Row>
      <Column1>Aerosmith</Column1>
      <Column2>http://www.aerosmith.com/detect.html</Column2>
      <Column3>0</Column3>
   </Row>
   <Row>
      <Column1>Foreigner</Column1>
      <Column2>http://www.foreigneronline.com/</Column2>
      <Column3>1</Column3>
   </Row>
   .
   .
   .
   <Row>
      <Column1>The Who</Column1>
      <Column2>http://www.thewho.net/</Column2>
      <Column3>4</Column3>
   </Row>
</EastCoastSales>
```

The corresponding schema would be something like this:

```xml
<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="Sheet1" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 
    <xs:element name="EastCoastSales" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> 
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="Row">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Column1" type="xs:string" minOccurs="0" />
                            <xs:element name="Column2" type="xs:string" minOccurs="0" />
                            <xs:element name="Column3" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>
```

## See Also

**Excel形式ファイルのインポート**
[Workbook Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-workbk)
[Chart Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-chart)
[Sheet Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-sheet)
[Row and Column Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-rowcol)
[Cell Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-cell)
[Border Styles Substituted](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-border)
[Formula Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-formulas)
[Print Settings Imported](/spreadnet/docs/latest/online-win/overview/spwin-impexpref/spwin-excelimport/spwin-excelimport-print)