Converting to XPS

Skip to end of metadata
Go to start of metadata
The XPS document format consists of structured XML markup that defines the layout of a document and the visual appearance of each page, along with rendering rules for distributing, archiving, rendering, processing and printing the documents. Notably, the markup language for XPS is a subset of XAML, allowing it to incorporate vector-graphic elements in documents, using XAML to mark up the Windows Presentation Foundation (WPF) primitives. The elements used are described in terms of paths and other geometrical primitives.

An XPS file is in fact a Unicoded ZIP archive using the Open Packaging Conventions, containing the files which make up the document. These include an XML markup file for each page, text, embedded fonts, raster images, 2D vector graphics, as well as the digital rights management information. The contents of an XPS file can be examined simply by opening it in an application which supports ZIP files.

You might require to convert Excel files to XPS files. Since the release of v6.0.0, Aspose.Cells supports Excel-to-XPS feature.

Example:

The following example shows how to use Excel--to-XPS feature.

[C#]
//Open an Excel file
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("e:\\test\\Book1.xls");
//Get the first worksheet
Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];

//Apply different Image and Print options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
//Set the Format
options.SaveFormat = SaveFormat.XPS;
//Render the sheet with respect to specified printing options
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);
sr.ToImage(0, "e:\\test2\\out_printingxps.xps");
 
[VB]
'Open an Excel file
Dim workbook As New Aspose.Cells.Workbook("e:\test\Book1.xls")
'Get the first worksheet
Dim sheet As Aspose.Cells.Worksheet = workbook.Worksheets(0)

'Apply different Image and Print options
Dim options As New Aspose.Cells.Rendering.ImageOrPrintOptions()
'Set the Format
options.SaveFormat = SaveFormat.XPS
'Render the sheet with respect to specified printing options
Dim sr As New Aspose.Cells.Rendering.SheetRender(sheet, options)
sr.ToImage(0, "e:\test2\out_printingxps.xps")
 

Export Whole Workbook to XPS

The following example shows how to convert the whole workbook to XPS format.

[C#]
//Export the whole workbook to XPS
Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(workbook, options);
wr.ToImage("e:\\test2\\out_printingxps.xps");
 
[VB]
' Export the whole workbook to XPS
Dim wr As New Aspose.Cells.Rendering.WorkbookRender(workbook, options)
wr.ToImage("e:\test2\out_printingxps.xps")
 

Example:
The following example shows a simple way on how to directly convert the Excel file to XPS format.

[C#]
//Export to XPS format
Workbook wb = new Workbook("e:\\test2\\Book1.xlsx");
wb.Save("e:\\test2\\out_test.xps", SaveFormat.XPS);
 
[VB]
'Export to XPS format
Dim wb As New Aspose.Cells.Workbook("e:\test2\Book1.xlsx")
wb.Save("e:\test2\out_test.xps", SaveFormat.XPS)
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.