Excel spreadsheets are useful in organizing, managing, and computing data. Similarly, HTML is useful for displaying content in the browser. Both formats are handy in their specific use cases. There might be cases where you have to show Excel data on websites. In those cases, HTML would be the better format to use. To achieve this, you will have to convert the required Excel file to HTML. In light of this, you will learn how to convert Excel files to HTML using C++.
- C++ Excel to HTML Converter API – Free Download
- Excel to HTML C++ Conversion
- C++ Excel to HTML Conversion with Additional Options
- Get a Free License
C++ Excel to HTML Converter API – Free Download
Aspose.Cells for C++ is a C++ native API for creating, converting, and manipulating Excel spreadsheets. You can use the API’s built-in converter to convert Excel files to HTML. Please install the API via NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Cells.Cpp
Excel to HTML C++ Conversion
The following are the steps to convert Excel files to HTML:
- Load the Excel file by using the IWorkbook class.
- Save the file as HTML by using the IWorkbook->Save(intrusive_ptrAspose::Cells::Systems::String fileName, Aspose::Cells::SaveFormat saveFormat) method.
The following is the C++ code snippet for converting Excel files to HTML:
C++ Excel to HTML Conversion with Additional Options
Aspose.Cells for C++ API provides the IHtmlSaveOptions class for customizing the converted HTML file. The following are the options provided by the IHtmlSaveOptions class.
Options provided by the IHtmlSaveOptions class
- AttachedFilesDirectory: The directory for saving the attached files.
- AttachedFilesUrlPrefix: Specify the URL prefix for the attached files.
- CellCssPrefix: Set the prefix for the CSS name.
- DefaultFontName: Specify the default font used when the original font does not exist.
- Encoding: Specify the encoding.
- ExpImageToTempDir: Indicate whether to export the images to a temp directory.
- ExportActiveWorksheetOnly: Indicate whether to export only the active worksheet or the whole workbook to HTML.
- ExportBogusRowData: Specify whether to export bogus bottom row data.
- ExportDataOptions: Specify whether to export only the table or all the data of the HTML file.
- ExportFrameScriptsAndProperties: Indicate whether to export frame scripts and properties.
- ExportGridLines: Indicates whether to export grid lines.
- ExportHiddenWorksheet: Specify whether to export the hidden worksheet to HTML.
- ExportImagesAsBase64: Specify whether to save the images in Base64 format.
- FullPathLink: Specify whether to use the full path link in sheet00x.htm,filelist.xml and tabstrip.htm.
- HiddenColDisplayType: Specify whether to export the hidden column (column with the width of 0) to HTML.
- HiddenRowDisplayType: Specify whether to export the hidden row (the row with the height of 0) to HTML.
- HtmlCrossStringType: Specify the behavior of the cells when the text is larger than the cell size.
- LinkTargetType: Specify the link target type in the HTML anchor tag.
- ParseHtmlTagInCell: Indicate to parse HTML tags in a cell.
- PresentationPreference: Set this to true to get a more beautiful HTML presentation.
Converting Excel to HTML with IHtmlSaveOptions
The following are the steps to convert Excel to HTML with additional options:
- Firstly, load the Excel file with the IWorkbook class.
- Create an instance of the IHtmlSaveOptions class.
- Set additional options with IHtmlSaveOptions class such as ExportHiddenWorksheet.
- Finally, save the Excel file as HTML by using the IWorkbook->Save(intrusive_ptrAspose::Cells::Systems::String fileName, intrusive_ptrAspose::Cells::ISaveOptions saveOptions) method.
The following code sample shows how to convert Excel files to HTML with additional options:
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert an Excel file to HTML using C++. Furthermore, you have seen different options to customize the Excel to HTML conversion, such as whether to export hidden worksheets. You can explore more about Aspose.Cells for C++ using documentation.