Prevent Exporting Hidden Worksheet Contents on Saving to HTML with C++
Contents
[
Hide
]
You can save Excel workbooks to HTML. However, if the workbook contains hidden worksheets, Aspose.Cells by default exports the hidden worksheet contents to the HTML output (_files) directory which contains files such as worksheets, images, tabstrip.htm, stylesheet.css, etc. Sometimes, exporting the content of the hidden worksheets this way isn’t appropriate. For example, if the hidden worksheet contains images that should not be exported to the _files directory.
Aspose.Cells provides the HtmlSaveOptions.GetExportHiddenWorksheet() property. By default, it is set to true and hidden worksheets are exported to HTML. If you set it false, Aspose.Cells will not export hidden worksheet contents.
#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\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"WorkbookWithHiddenContent.xlsx";
// Path of output HTML file
U16String outputFilePath = outDir + u"HtmlWithoutHiddenContent_out.html";
// Create workbook object
Workbook workbook(inputFilePath);
// Create HTML save options
HtmlSaveOptions options;
// Do not export hidden worksheet contents
options.SetExportHiddenWorksheet(false);
// Save the workbook
workbook.Save(outputFilePath, options);
std::cout << "Workbook saved successfully without hidden content!" << std::endl;
Aspose::Cells::Cleanup();
}