Skip to main content

SpreadsheetControl.ExportToPdf(Stream) Method

Exports the content of the SpreadsheetControl to the specified stream in PDF format.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v24.1.dll

NuGet Package: DevExpress.Win.Spreadsheet

Declaration

public void ExportToPdf(
    Stream stream
)

Parameters

Name Type Description
stream Stream

A Stream object to which the created document is exported.

Remarks

Refer to the Export to PDF document to learn about PDF export features and limitations.

Example

Use the IWorkbook.ExportToPdf method to save a workbook as a PDF file.

The following code sample generates a PDF file from a workbook and saves it to a stream:

View Example

using DevExpress.Spreadsheet;
using System.IO;
//...

// Access a workbook.
IWorkbook workbook = spreadsheetControl.Document;

// Load a document.
workbook.LoadDocument(@"Documents\Document.xlsx", DocumentFormat.Xlsx);

// Save the workbook as a PDF file.
using (FileStream pdfFileStream = new FileStream(@"Documents\Document_PDF.pdf", FileMode.Create)) 
{
    workbook.ExportToPdf(pdfFileStream);
}
See Also