Convert Excel to HTML with tooltip using C++
Convert Excel to HTML with tooltip
There might be cases where the text is cut off in the generated HTML and you want to display the complete text as a tooltip on the hover event. Aspose.Cells supports this by providing HtmlSaveOptions.GetAddTooltipText() property. Setting the HtmlSaveOptions.GetAddTooltipText() property to true will add the complete text as a tooltip in the generated HTML.
The following image shows the tooltip in the generated HTML file.
The following code sample loads the source excel file and generates the output HTML file with the tooltip.
Sample Code
#include <iostream>
#include "Aspose.Cells.h"
#include "Aspose.Cells/HtmlSaveOptions.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
// Source directory path
U16String sourceDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outputDir(u"..\\Data\\02_OutputDirectory\\");
// Open the template file
Workbook workbook(sourceDir + u"AddTooltipToHtmlSample.xlsx");
// Setup HTML save options
HtmlSaveOptions options;
options.SetAddTooltipText(true); // Enable tooltip text in output
// Save as HTML
workbook.Save(outputDir + u"AddTooltipToHtmlSample_out.html", options);
std::cout << "Workbook saved with tooltip text added!" << std::endl;
Aspose::Cells::Cleanup();
}