How to Convert Excel to XPS in C# .NET

In this step by step tutorial, we’ll explain how to convert Excel to XPS in C# project. The code sample in this how-to topic shows that you can convert Excel to XPS in C# without Microsoft Excel. This does not required Microsoft Interop either.

Steps to Convert Excel to XPS in C#

  1. Get Aspose.Cells for .NET API from NuGet.org
  2. Add reference to Aspose.Cells namespace
  3. Use SetLicense method to apply the license
  4. Create an object of Workbook class
  5. Load input Excel (XLSX or XLS) to be converted to XPS
  6. Save the Converted XPS file using Xps SaveFormat

In this example, we are converting XLSX to XPS in C#, but by using the same code and steps you can also convert XLS to XPS in C# applications and projects. The code and the process is same in both cases.

C# Code to Convert Excel to XPS in C#

As the above code snippet shows, the conversion can be easily done using just two lines of code of the API. Just like we wrote a how-to topic to export large Excel file to CSV in C# without using Interop or Excel, it is important to note that we have converted Excel to XPS in C# without Microsoft Excel and interop as well. So you can run this code anywhere without installing Excel. That means the code can run on the server and in Windows or ASP.NET applications alike.

 English