使用C++导出评论并保存Excel文件为HTML
Contents
[
Hide
]
可能的使用场景
将Excel保存为HTML时,评论不会被导出。但是,Aspose.Cells通过HtmlSaveOptions.IsExportComments属性提供此功能。如果将其设置为true,HTML中也会显示Excel文件中的评论。
在将 Excel 文件保存为 HTML 时导出批注
下面的示例代码演示了HtmlSaveOptions.IsExportComments属性的用法。截图显示将其设置为true时,HTML的效果。请下载示例Excel文件和生成的HTML以供参考。
示例代码
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Load sample Excel file
U16String sourceDir(u"..\\Data\\01_SourceDirectory\\");
U16String inputFilePath = sourceDir + u"sampleExportCommentsHTML.xlsx";
Workbook workbook(inputFilePath);
// Export comments - set IsExportComments property to true
HtmlSaveOptions opts;
opts.SetIsExportComments(true);
// Save the Excel file to HTML
U16String outputDir(u"..\\Data\\02_OutputDirectory\\");
workbook.Save(outputDir + u"outputExportCommentsHTML.html", opts);
std::cout << "Excel file exported to HTML with comments successfully!" << std::endl;
Aspose::Cells::Cleanup();
}