How to: Export a Worksheet with Embedded Charts to PDF
To export a workbook to PDF, use the Workbook.ExportToPdf method.
However, to export embedded charts, it is necessary to register the following services:
- DevExpress.XtraSpreadsheet.Services.Implementation.ChartControllerFactoryService
- DevExpress.XtraSpreadsheet.Services.Implementation.ChartImageService
The code snippet below illustrates how to accomplish the task.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-export-a-worksheet-with-embedded-charts-to-pdf-t269520
Imports DevExpress.Spreadsheet
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraSpreadsheet.Services
Imports DevExpress.XtraSpreadsheet.Services.Implementation
Dim workbook As New Workbook()
'Register required services.
workbook.AddService(GetType(IChartControllerFactoryService), New ChartControllerFactoryService())
workbook.AddService(GetType(IChartImageService), New ChartImageService())
workbook.LoadDocument("testDocument.xlsx")
workbook.ExportToPdf("resultingDocument.pdf")