# Export

## Content

FlexPivot provides various methods to save its content in the desired format such as XML, Excel, and PDF at runtime or through code. At runtime, you can use the **Export** and **Print** options on the FlexPivot Toolstrip to export the content as excel and pdf, respectively. For exploring these options, see [Toolstrip](/componentone/docs/win/online-flexpivot/).

Now, lets explore how to export FlexPivot and its content to different formats using code.

### Export to PDF

To export FlexPivot and its content as pdf, you can use the **PrintDocument** class. You can simply set the value of **PrinterName** property to "**Microsoft Print to PDF** and use **Print** method of the **PrintDocument** class as demonstrated in the following code.

```csharp
//Saves content as PDF
var printDocument = flexPivotPage1.Document;
printDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF";
printDocument.Print();  
```

### Save as XML

To serialize the contents into an XML document, you can simply call **WriteXml** method of the [C1FlexPivotGrid](/componentone/api/win/online-flexpivot/dotnet-api/C1.Win.FlexPivot.10/C1.Win.FlexPivot.C1FlexPivotGrid.html) class and parse path of the XML document as a parameter. The method serializes all grid contents into the XML document, including the data stored in the cells, row and column properties.

To save the grid content as XML, use the following code. This code exports all the content to an XML file named ExportedData in the bin directory of the project folder.

```csharp
//Saves content as XML
flexPivotPage1.FlexPivotGrid.WriteXml("../../ExportedData.xml");        
```