在本教程中,我们将探索如何使用 C++** 将 Excel 转换为 PDF。 Excel 文件通常用于处理涉及计算的数据,例如您可以执行不同的操作和计算来处理数据。您可以使用简单的 API 接口使用 C++ 执行 Excel 到 PDF 的转换,而不依赖于 MS Excel。
使用 C++ 将 Excel 转换为 PDF 的步骤
- 使用 NuGet 包管理器配置 Aspose.Cells.Cpp 包
- 添加对 Aspose::Cells 命名空间的引用
- 实例化 Workbook Class 对象以加载输入 Excel 文件
- 使用 Save 方法保存输出 PDF 文件
您可以按照下面的示例使用 C++ 将任何 Excel 文件保存为 PDF*。只有几个简单的 API 调用可以让您快速执行此任务。
使用 C++ 将 Excel 文件转换为 PDF 的代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Aspose.Cells.h" | |
using namespace std; | |
class ExcelToPDFEx | |
{ | |
public: | |
void ConvertExcelWorkbookToPDF() | |
{ | |
// Set Aspose.Cells API License | |
intrusive_ptr<License> LicenseForExcelToPDF = new License(); | |
LicenseForExcelToPDF->SetLicense(new String("Aspose.Cells.NET.lic")); | |
// Load the sample input Excel | |
intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Factory::CreateIWorkbook(new String("input.xlsx")); | |
// Save the output Excel Document in PDF format | |
workbook->Save(new String("OutputExcelToPDF.pdf"), SaveFormat_Pdf); | |
} | |
}; |
在上一篇文章中,我们探讨了 如何使用 C# 将 Excel 文件另存为 PDF。而在本分步指南中,我们学习了 *Excel 到 C++ 中的 PDF 转换 *。