Enable CSS Custom Properties while saving to HTML with C++

Possible Usage Scenarios

When you save your Excel file to HTML, for scenarios where there are multiple occurrences of the same base64 image, the custom property allows the image data to be saved only once, improving the performance of the resulting HTML. Please use HtmlSaveOptions.GetEnableCssCustomProperties() property and set it to true while saving to HTML.

todo:image_alt_text

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 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 CSS custom properties
    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();
}