Convert Excel Files to PDF using C++

Excel to pdf C++

PDF format is widely used to exchange documents among the stakeholders. In various cases, the documents are converted to PDF format before they are shared. Thus, PDF is known to be a standard file format in such cases. In this article, we will target Excel to PDF conversion programmatically. Particularly, you will learn how to convert Excel XLSX or XLS workbooks to PDF files using C++.

C++ Excel to PDF Converter API

Aspose.Cells for C++ is designed to implement Excel automation features within C++ applications. Using the API, you can create new Excel files from scratch as well as manipulate the existing ones. The API’s built-in spreadsheet converter lets you convert Excel files to other formats with high fidelity. You can either download the API package or install it from NuGet.

Install-Package Aspose.Cells.Cpp

Convert Excel Files to PDF in C++

The following are the steps to convert Excel files to PDF using Aspose.Cells.

The following code sample shows how to convert Excel files to PDF using C++.

C++ Excel to PDF with Compliance Level

Aspose.Cells for C++ also allows you to set the compliance level of the converted PDF file such as PDF/A. For this, the API provides an additional class named as IPdfSaveOptions that allows you to customize the Excel to PDF conversion with different options. The following are the steps to convert an Excel file to PDF with PDF/A compliance.

The following code sample shows how to set compliance level in Excel to PDF conversion.

Set PDF Creation Date in Excel to PDF

You can also set the creation date and time for the converted PDF file. For this, you can simply use IPdfSaveOptions->SetCreatedTime(new Aspose::Cells::Systems::DateTime) method. The following are the steps to perform this operation.

The following code sample shows how to set the creation date and time in Excel to PDF conversion.

Get a Free License

You can get a free temporary license in order to try the API without evaluation limitations.

Conclusion

In this article, you have learned how to convert Excel files to PDF using C++. Furthermore, you have seen how to set the compliance level and the creation date for the converted PDF file. You can explore more about the API using documentation.

See Also