Create, View, Edit and Save Your Excel Files Using WPF Spreadsheet
Tags: excel, spreadsheet, wpf, productivity
Published: 2021-08-10 12:50:28

---
title: Create, View, Edit and Save Your Excel Files Using WPF Spreadsheet
published: true
date: 2021-08-10 10:00:21 UTC
tags: Excel,Spreadsheet,WPF,productivity
canonical_url: https://www.syncfusion.com/blogs/post/create-view-edit-and-save-your-excel-files-using-wpf-spreadsheet.aspx
cover_image: https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Create-View-Edit-and-Save-Your-Excel-Files-Using-WPF-Spreadsheet-672x372.png
---

Spreadsheets are the heart of data analysis and storage. Almost everyone uses spreadsheets at some point, for personal use or for business.

Our Syncfusion [WPF Spreadsheet](https://www.syncfusion.com/wpf-ui-controls/spreadsheet "Link to WPF Spreadsheet") is an Excel-inspired control that allows you to create, view, edit, and format [Microsoft Excel](https://en.wikipedia.org/wiki/Microsoft_Excel "Link to Microsoft Excel Wikipedia page") files without having Microsoft Excel installed. It provides an integrated ribbon to cover any possible business scenario. In addition, this control supports a built-in calculation engine with more than 400 widely used formulas. It was built with the [.NET Excel Library](https://www.syncfusion.com/excel-framework/net "Link to .NET Excel Library") (Essential XlsIO), which features a full-fledged object model similar to the Microsoft Office automation libraries.

In this blog, I will explain how to create, read, and edit an Excel file using our Syncfusion WPF Spreadsheet control.

**Note:** If you are new to our Spreadsheet control, then please read the [Getting Started with WPF Spreadsheet](https://help.syncfusion.com/wpf/spreadsheet/getting-started "Link to Getting Started with WPF Spreadsheet documentation") documentation before proceeding.

## Create a simple Spreadsheet project

The following steps illustrate how to create a simple Spreadsheet project in WPF:

1. First, open **Visual Studio** and select  **Create a New Project**.
2. Then, the New Project dialog will open. Choose  **WPF Application**  from the dropdown list and provide a name for your application. Refer to the following screenshot.

![Create a New WPF Project](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Create-a-new-WPF-project.png)<figcaption>Create a New WPF Project</figcaption>

3. Now, install the [Syncfusion.SfSpreadsheet.WPF](https://www.nuget.org/packages/Syncfusion.SfSpreadsheet.WPF/ "Link to the Syncfusion.SfSpreadsheet.WPF NuGet package") NuGet package as a reference to your .NET Framework app from [Nuget.org](https://www.nuget.org/ "Link to the NuGet Gallery").

![Install the Syncfusion.SfSpreadsheet.WPF NuGet Package](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Install-the-Syncfusion.SfSpreadsheet.WPF-NuGet-package.png)<figcaption>Install the Syncfusion.SfSpreadsheet.WPF NuGet Package</figcaption>

The spreadsheet is available in the namespace **Syncfusion.UI.Xaml.Spreadsheet** and you can create it programmatically either by using the XAML or C# code.

1. Next, add the **SpreadsheetRibbon** and bind the Spreadsheet as the DataContext to the SpreadsheetRibbon to make an interaction between the ribbon items and Spreadsheet.

1. To add the SpreadsheetRibbon to your application, use the RibbonWindow since the backstage of the ribbon will open only when the ribbon is loaded under the RibbonWindow.  
Refer to the following code.
```html
<syncfusion:RibbonWindow x:Class="SpreadsheetDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup- compatibility/2006"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d">
<syncfusion:SfSpreadsheetRibbon DataContext= "{Binding ElementName=spreadsheet}" />
<syncfusion:SfSpreadsheet x:Name="spreadsheet"/>
</ syncfusion:RibbonWindow >

```

Now, we have created a simple WPF Spreadsheet project.

## Create a new Excel workbook

You can create a new workbook by using the [Create](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Spreadsheet.SfSpreadsheet.html#Syncfusion_UI_Xaml_Spreadsheet_SfSpreadsheet_Create_System_Int32_ "Link to the Create method of WPF Spreadsheet") method. By default, a workbook will be created with a single worksheet. Use the following code to load the Spreadsheet workbook with a specified number of worksheets.

```csharp
spreadsheetControl.Create(2);
```

Also, you can add new worksheets on-demand in the WPF Spreadsheet control by clicking the **AddNew** button. Refer to the following screenshot.

![Creating an Excel Workbook Using WPF Spreadsheet](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Creating-an-Excel-Workbook-Using-WPF-Spreadsheet.png)<figcaption>Creating an Excel Workbook Using WPF Spreadsheet</figcaption>

## View the existing Excel sheet

The following code snippet illustrates how to view Excel files using the WPF Spreadsheet control.

```csharp
/// View the Excel file.
spreadsheetControl.Open (@"..\..\Data\GettingStarted.xlsx");
                   (or)
ExcelEngine excelEngine = new ExcelEngine();
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(@"..\..\Data\GettingStarted.xlsx");
spreadsheetControl.Open(workbook);
                   (or)
using (FileStream fileStream = new FileStream(@"..\..\Data\ GettingStarted.xlsx”, FileMode.Open))
{
     spreadsheetControl.Open(fileStream);
}
```

Also, you can open the existing Excel files by clicking  **Open** in the **SpreadsheetRibbon** backstage, like in the following screenshot.

![Opening an Existing Excel File Using WPF Spreadsheet](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Opening-an-Existing-Excel-File-Using-WPF-Spreadsheet.png)<figcaption>Opening an Existing Excel File Using WPF Spreadsheet</figcaption>

## Edit the values in an Excel file

The Spreadsheet provides support for editing, so you can modify and commit the cell values in a workbook. The following code snippet illustrates how to edit data in an Excel file using the WPF Spreadsheet control.

```csharp
/// Editing a specific cell value.
var range = spreadsheetControl.ActiveSheet.Range[2,2];
spreadsheetControl.ActiveGrid.SetCellValue(range, "Syncfusion");
spreadsheetControl.ActiveGrid.InvalidateCell(2,2);

```

Refer to the following screenshot.

![Editing the Cell Values in an Excel File Using WPF Spreadsheet](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Editing-the-Cell-Values-in-an-Excel-File-Using-WPF-Spreadsheet.png)<figcaption>Editing the Cell Values in an Excel File Using WPF Spreadsheet</figcaption>

## Saving an Excel sheet

You can save Excel workbooks using the Save() method. If the workbook already exists in the system drive, then it will be saved in the same location. Otherwise, the **Save** dialog box will open to let you save the workbook in a specified location.

Refer to the following code snippet.

```csharp
/// Save the changes made in the file. If the file is not created yet, then it prompts to enter the filename to save.
spreadsheetControl.Save();

/// Save the changes made in the file using the SaveFileDialog.
spreadsheetControl.SaveAs();
```

Also, you can save the Excel files using  **Save** or **SaveAs**  in the ribbon backstage.

![Saving an Excel File Using WPF Spreadsheet](https://www.syncfusion.com/blogs/wp-content/uploads/2021/08/Saving-an-Excel-File-Using-WPF-Spreadsheet.png)<figcaption>Saving an Excel File Using WPF Spreadsheet</figcaption>

## GitHub reference

You can download the complete sample from [Create, View, Edit, and Save Excel Files Using WPF Spreadsheet demo](https://github.com/SyncfusionExamples/create-view-edit-excel-files-using-wpf-spreadsheet "Link to Create, View, Edit Excel Files Using WPF Spreadsheet demo on GitHub").

## Conclusion

Thanks for reading! In this blog post, we gave a quick overview of how to create, view, edit, and save  Excel files using the Syncfusion [WPF Spreadsheet](https://www.syncfusion.com/wpf-ui-controls/spreadsheet "Link to WPF Spreadsheet") control. This control also supports hyperlinks, bookmarks, encryption, localization, cell formatting, and more. Try out these versatile features and share your feedback in the comments section of this blog post!

The Spreadsheet control is also available in our ASP.NET ([Core](https://www.syncfusion.com/aspnet-core-ui-controls/spreadsheet "Link to ASP.NET Core Spreadsheet"), [MVC](https://www.syncfusion.com/aspnet-mvc-ui-controls/spreadsheet "Link to ASP.NET MVC Spreadsheet"), [Web Forms](https://www.syncfusion.com/jquery/aspnet-web-forms-ui-controls "Link to ASP.NET Web Forms Spreadsheet")), [JavaScript](https://www.syncfusion.com/javascript-ui-controls/js-spreadsheet "Link to JavaScript Spreadsheet"), [Angular](https://www.syncfusion.com/angular-ui-components "Link to Angular Spreadsheet"), [React](https://www.syncfusion.com/react-ui-components/react-spreadsheet "Link to React Spreadsheet"), [Vue](https://www.syncfusion.com/vue-ui-components/vue-spreadsheet "Link to Vue Spreadsheet"), [UWP](https://www.syncfusion.com/uwp-ui-controls/spreadsheet "Link to UWP Spreadsheet"), [WinForms](https://www.syncfusion.com/winforms-ui-controls/spreadsheet "Link to WinForms Spreadsheet"), and [WPF](https://www.syncfusion.com/wpf-controls/spreadsheet "Link to WPF Spreadsheet") platforms.

If you are an existing Syncfusion user, please download the latest version from the [License and Downloads](https://www.syncfusion.com/account/downloads "Link to license and download page of Essential Studio") page and try the new features for yourself. Also, our NuGet packages are available on [NuGet.org](https://www.nuget.org/ "Link to the NuGet Gallery").

If you aren’t a customer yet, you can try our 30-day [free trial](https://www.syncfusion.com/downloads "Link to the free evaluation of the Syncfusion Essential Studio") to check out these features. Also, try our other demos from this [GitHub](https://github.com/SyncfusionExamples "Link to the Syncfusion examples on GitHub") repository.

You can also contact us through our [support forums](https://www.syncfusion.com/forums "Link to the Syncfusion support forum"), [Direct-Trac](https://www.syncfusion.com/support/directtrac/incidents "Link to the Syncfusion support system Direct Trac"), or [feedback portal](https://www.syncfusion.com/feedback/ "Link to Syncfusion Feedback Portal"). We are always happy to assist you!

## Related blogs

- [How to Interact with the WPF Scheduler Using a Keyboard](https://dev.to/karthickramasamy08/how-to-interact-with-the-wpf-scheduler-using-a-keyboard-22jp-temp-slug-8930085 "Link to How to Interact with the WPF Scheduler Using a Keyboard blog")
- [Enjoy 30+ New, Elegant Palettes in WPF Theme Studio](https://dev.to/karthickramasamy08/enjoy-30-new-elegant-palettes-in-wpf-theme-studio-100p-temp-slug-2451018 "Link to Enjoy 30+ New, Elegant Palettes in WPF Theme Studio blog")
- [Add, Edit, and Delete Cloud Shapes in PDF Files with Ease in WPF](https://dev.to/karthickramasamy08/add-edit-and-delete-cloud-shapes-in-pdf-files-with-ease-in-wpf-4l52-temp-slug-4649139 "Link to Add, Edit, and Delete Cloud Shapes in PDF Files with Ease in WPF blog")
- [Simple Steps to Design a Temperature Monitor Using WPF Radial Gauge](https://dev.to/syncfusion/simple-steps-to-design-a-temperature-monitor-using-wpf-radial-gauge-p36 "Link to Simple Steps to Design a Temperature Monitor Using WPF Radial Gauge blog")