# Export to Excel

## Content

FlexGrid allows you to export files to CSV, PDF, Xlsx/Xlsm, and HTML file formats with the help of the **C1.WPF.Grid.Excel** library. This library provides [SaveAsync](/componentone/api/wpf/online-flexgrid/dotnet-api/C1.WPF.Grid.Excel/C1.WPF.Grid.Extensions.SaveAsync.html) method in the [Extensions](/componentone/api/wpf/online-flexgrid/dotnet-api/C1.WPF.Grid.Excel/C1.WPF.Grid.Extensions.html) class which can be used to export FlexGrid and save it to either the file system or a Stream. The SaveAsync method has two overloads depending on whether you need to save to a stream or the file system:

| **Overloads** | **Description** |
| --------- | ----------- |
| **SaveAsync(C1.WPF.Grid.FlexGrid,System.String,System.String,GrapeCity.Documents.Excel.SaveFileFormat,**<br>**C1.WPF.Grid.GridRowColRanges,C1.WPF.Grid.GridRowColRanges,C1.WPF.Grid.GridHeadersVisibility,System.Boolean,**<br>**System.Boolean,System.Boolean,System.Drawing.Printing.PrinterSettings)** | Saves the contents of the grid in a desired file format using GcExcel. |
| **SaveAsync(C1.WPF.Grid.FlexGrid,System.IO.Stream,System.String,GrapeCity.Documents.Excel.SaveFileFormat,**<br>**C1.WPF.Grid.GridRowColRanges,C1.WPF.Grid.GridRowColRanges,C1.WPF.Grid.GridHeadersVisibility,System.Boolean,**<br>**System.Boolean,System.Boolean,System.Drawing.Printing.PrinterSettings)** | Saves the contents of the grid in a stream in desired format using GcExcel. |

To export FlexGrid to any other format, you need to add the following dependencies to your application:

* using **C1.WPF.Grid**;
* using **GrapeCity.Documents.Excel**;

The following example shows how to use the SaveAsync method to export FlexGrid to Excel files with XLSX/XSLM format. In this example, we used the **Name** property to name the FlexGrid control as "flex".

```csharp
private void Save_Click(object sender, RoutedEventArgs e)
{          
    flex.SaveAsync(@"..\..\..\..\FlexGridSheet_overload2.xlsx","flex Sheet",SaveFileFormat.Xlsx, new GridRowColRanges("1-3", GridRowColRangesOptions.VisibleOnly), new GridRowColRanges("1-3", GridRowColRangesOptions.VisibleOnly), GridHeadersVisibility.All, false,false, false, null);
}
```