Enable CSS Custom Properties while saving to HTML with C++
Possible Usage Scenarios
When you save your Excel file to HTML, for the scenario that there are multiple occurrences for one base64 image, with custom property the image data only needs to be saved once so the performance of the resultant HTML can be improved. Please use HtmlSaveOptions.GetEnableCssCustomProperties() property and set it to true while saving to HTML.
Enable CSS Custom Properties while saving to HTML
The following sample code shows the usage of HtmlSaveOptions.GetEnableCssCustomProperties() property. The screenshot shows the effect of this property when it is not set to true. Please download the sample Excel file used in this code and the output HTML generated by it for a reference.
Sample Code
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Load sample workbook
Workbook wb(srcDir + u"sampleEnableCssCustomProperties.xlsx");
// Create HtmlSaveOptions object
HtmlSaveOptions opts;
// Set ExportImagesAsBase64 to true
opts.SetExportImagesAsBase64(true);
// Enable EnableCssCustomProperties
opts.SetEnableCssCustomProperties(true);
// Save the workbook in HTML format
wb.Save(outDir + u"outputEnableCssCustomProperties.html", opts);
std::cout << "Workbook saved successfully with CSS custom properties enabled!" << std::endl;
Aspose::Cells::Cleanup();
}