[]
Use this class to configure HTML-specific export settings such as tooltip text, CSS export behavior, worksheet export options, attached-file URLs, and related output behavior before saving workbook content as HTML.
worksheet.getRange("A1:D4").setValue(new Object[][] {
{"Region", "Q1", "Q2", "Q3"},
{"North", 120, 130, 140}
});
worksheet.setName("QuarterlyReport");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportHeadings(true);
options.setExportGridlines(true);
options.setExportArea("A1:D4");
options.setExportSheetName("QuarterlyReport");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
workbook.save(stream, options);
final booleanfinal Stringfinal Stringfinal CssExportTypefinal Stringfinal Stringfinal booleanfinal booleanfinal Stringfinal booleanfinal booleanfinal booleanfinal booleanfinal Stringfinal booleansetExportSheetName(String) specifies a worksheet to export.final booleanfinal booleanfinal booleanfinal booleanfinal HyperLinkTargetTypefinal Stringfinal Stringtr and td, that are contained in the table element with the specific TableCssId attribute.final voidsetAddTooltipText(boolean value) final voidsetAttachedFilesUrlPrefix(String value) voidfinal voidsetCellCssPrefix(String value) final voidsetCssExportType(CssExportType value) final voidsetEncoding(String value) final voidsetExportArea(String value) final voidsetExportCssSeparately(boolean value) setCssExportType(CssExportType) instead.final voidsetExportDocumentProperties(boolean value) final voidsetExportFileName(String value) final voidsetExportGridlines(boolean value) final voidsetExportHeadings(boolean value) final voidsetExportHiddenWorksheet(boolean value) final voidsetExportImageAsBase64(boolean value) final voidsetExportSheetName(String value) final voidsetExportSingleTab(boolean value) setExportSheetName(String) specifies a worksheet to export.final voidsetIncludeAutoMergedCells(boolean value) final voidsetIsExportComments(boolean value) final voidsetIsFullPathLink(boolean value) final voidsetIsWidthScalable(boolean value) final voidfinal voidsetPageTitle(String value) final voidsetTableCssId(String value) tr and td, that are contained in the table element with the specific TableCssId attribute.getFileFormat, setFileFormatThis constructor initializes a new HtmlSaveOptions instance and sets its file format to SaveFileFormat.Html. Use the created object to configure HTML-specific export settings before saving.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSingleTab(true);
options.setAddTooltipText(true);
workbook.save("path/to/output.html", options);
The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setAddTooltipText(true);
boolean addTooltipText = options.getAddTooltipText();
workbook.save("path/to/output.html", options);
true if tooltip text is added for truncated data in the exported HTML; otherwise, false.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setAddTooltipText(true);
workbook.save("path/to/output.html", options);
value - true if tooltip text is added for truncated data in the exported HTML; otherwise, false.This property is used only when saving to a ZIP stream. The default value is "workbook".
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportFileName("report");
String fileName = options.getExportFileName();
workbook.save("path/to/output.html", options);
"workbook" if no custom name has been set.This property is used only when saving to a ZIP stream. The default value is "workbook".
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportFileName("report");
workbook.save("path/to/output.html", options);
value - The name of the HTML file used when saving to a ZIP stream. Sets "workbook" if no custom name has been set.This value is used when generating URLs for files that are exported alongside the HTML content. If no prefix has been specified, this method returns null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setAttachedFilesUrlPrefix("resources/");
String urlPrefix = options.getAttachedFilesUrlPrefix();
workbook.save("path/to/output.html", options);
null if no prefix has been specified.This value is used when generating URLs for files that are exported alongside the HTML content. If no prefix has been specified, this method Sets null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setAttachedFilesUrlPrefix("resources/");
workbook.save("path/to/output.html", options);
value - The URL prefix for attached files, or null if no prefix has been specified.The default value is null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setCellCssPrefix("cell-");
String cssPrefix = options.getCellCssPrefix();
workbook.save("path/to/output.html", options);
null if no prefix is specified.The default value is null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setCellCssPrefix("cell-");
workbook.save("path/to/output.html", options);
value - The prefix of the CSS class names. Sets null if no prefix is specified.If no encoding has been set, the default value is UTF-8.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setEncoding("UTF-16");
String encoding = options.getEncoding();
workbook.save("path/to/output.html", options);
UTF-8 by default.If no encoding has been set, the default value is UTF-8.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setEncoding("UTF-16");
workbook.save("path/to/output.html", options);
value - The encoding name used for HTML export. Sets UTF-8 by default.This option controls whether the workbook's document properties are included in the generated HTML output. The default value is true. Use setExportDocumentProperties(boolean) to change this setting.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportDocumentProperties(false);
boolean exportDocumentProperties = options.getExportDocumentProperties();
workbook.save("path/to/output.html", options);
true if document properties are exported to HTML; otherwise, false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportDocumentProperties(false);
workbook.save("path/to/output.html", options);
value - true if document properties are exported to HTML; otherwise, false.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportGridlines(true);
boolean exportGridlines = options.getExportGridlines();
workbook.save("path/to/output.html", options);
true if worksheet gridlines are exported to HTML; otherwise, false.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportGridlines(true);
workbook.save("path/to/output.html", options);
value - true if worksheet gridlines are exported to HTML; otherwise, false.This property controls whether row and column headings are included in the exported HTML output. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportHeadings(true);
boolean exportHeadings = options.getExportHeadings();
workbook.save("path/to/output.html", options);
true if headings are exported when saving to HTML; otherwise, false.This property controls whether row and column headings are included in the exported HTML output. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportHeadings(true);
workbook.save("path/to/output.html", options);
value - true if headings are exported when saving to HTML; otherwise, false.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportHiddenWorksheet(true);
boolean exportHiddenWorksheet = options.getExportHiddenWorksheet();
workbook.save("path/to/output.html", options);
true if hidden worksheets are exported when saving to HTML; otherwise, false.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportHiddenWorksheet(true);
workbook.save("path/to/output.html", options);
value - true if hidden worksheets are exported when saving to HTML; otherwise, false.The default value is false. When this property is true, image data is exported directly on the img elements and separate files are not created.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportImageAsBase64(true);
boolean exportImageAsBase64 = options.getExportImageAsBase64();
workbook.save("path/to/output.html", options);
true if images are saved in Base64 format to html; otherwise, false.The default value is false. When this property is true, image data is exported directly on the img elements and separate files are not created.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportImageAsBase64(true);
workbook.save("path/to/output.html", options);
value - true if images are saved in Base64 format to html; otherwise, false.getCssExportType() instead.The default value is true. When this property is false, CSS style data is exported directly to each worksheet and a separate stylesheet.css file is not created.
true if the worksheet style is exported to a separate CSS file; otherwise, false.setCssExportType(CssExportType) instead.The default value is true. When this property is false, CSS style data is exported directly to each worksheet and a separate stylesheet.css file is not created.
value - true if the worksheet style is exported to a separate CSS file; otherwise, false.setExportSheetName(String) specifies a worksheet to export.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSingleTab(true);
boolean exportSingleTab = options.getExportSingleTab();
workbook.save("path/to/output.html", options);
true if a single HTML tab is exported when the workbook has only one worksheet or an export sheet name is specified; otherwise, false.setExportSheetName(String) specifies a worksheet to export.The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSingleTab(true);
workbook.save("path/to/output.html", options);
value - true if a single HTML tab is exported when the workbook has only one worksheet or an export sheet name is specified; otherwise, false.This option applies to HTML export and determines whether cell comments are included in the generated HTML output. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsExportComments(true);
boolean exportComments = options.getIsExportComments();
workbook.save("path/to/output.html", options);
true if comments are exported when saving to HTML; otherwise, false.This option applies to HTML export and determines whether cell comments are included in the generated HTML output. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsExportComments(true);
workbook.save("path/to/output.html", options);
value - true if comments are exported when saving to HTML; otherwise, false.This property applies only when exporting to an HTML file. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsFullPathLink(true);
boolean isFullPathLink = options.getIsFullPathLink();
workbook.save("path/to/output.html", options);
true if hyperlinks in the exported HTML use full paths; otherwise, false.This property applies only when exporting to an HTML file. The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsFullPathLink(true);
workbook.save("path/to/output.html", options);
value - true if hyperlinks in the exported HTML use full paths; otherwise, false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setLinkTargetType(HyperLinkTargetType.Self);
HyperLinkTargetType linkTargetType = options.getLinkTargetType();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
workbook.save(outputStream, options);
Use this method to control how generated hyperlinks are opened in the target environment, such as in the same frame, parent frame, or a new window or tab.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setLinkTargetType(HyperLinkTargetType.Self);
workbook.save("path/to/output.html", options);
value - The hyperlink target type to apply to exported HTML links.Use this method to retrieve the page title configured by setPageTitle(String) for HTML export.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setPageTitle("Sales Report");
String pageTitle = options.getPageTitle();
workbook.save("path/to/output.html", options);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setPageTitle("Sales Report");
workbook.save("path/to/output.html", options);
value - The title of the HTML page.tr and td, that are contained in the table element with the specific TableCssId attribute. The default value is null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setTableCssId("salesTable");
String tableCssId = options.getTableCssId();
workbook.save("path/to/output.html", options);
null if it is not set.tr and td, that are contained in the table element with the specific TableCssId attribute. The default value is null.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setTableCssId("salesTable");
workbook.save("path/to/output.html", options);
value - The prefix of the type CSS names for the table element with the specific TableCssId attribute, or null if it is not set.This option controls how column width information is written during HTML export. The default value is false. See setIsWidthScalable(boolean).
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsWidthScalable(true);
boolean isWidthScalable = options.getIsWidthScalable();
workbook.save("path/to/output.html", options);
true if scalable units are used for column widths during HTML export; otherwise, false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIsWidthScalable(true);
workbook.save("path/to/output.html", options);
value - true if scalable units are used for column widths during HTML export; otherwise, false.Use this property to determine which worksheet has been selected for HTML export. This setting is used when exporting a specific worksheet from a workbook.
worksheet.setName("QuarterlyReport");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSheetName("QuarterlyReport");
String sheetName = options.getExportSheetName();
workbook.save("path/to/output.html", options);
Use this property to specify which worksheet has been selected for HTML export.
worksheet.setName("QuarterlyReport");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSheetName("QuarterlyReport");
workbook.save("path/to/output.html", options);
value - The name of the worksheet configured for HTML export.This property is used to export a specific area of a worksheet. It only takes effect when getExportSheetName() is not null. Use setExportArea(String) to specify the area reference, such as "A2:G23".
worksheet.setName("QuarterlyReport");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSheetName("QuarterlyReport");
options.setExportArea("A1:D4");
String exportArea = options.getExportArea();
workbook.save("path/to/output.html", options);
worksheet.setName("QuarterlyReport");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportSheetName("QuarterlyReport");
options.setExportArea("A1:D4");
workbook.save("path/to/output.html", options);
value - The area reference configured for HTML export.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setCssExportType(CssExportType.External);
CssExportType cssExportType = options.getCssExportType();
workbook.save("path/to/output.html", options);
Use CssExportType to control whether CSS is exported to an external CSS file, within the HTML style tag, or as inline style attributes on HTML elements.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setCssExportType(CssExportType.External);
workbook.save("path/to/output.html", options);
value - The CSS export type.This option applies to auto-merge information added by IWorksheet.autoMerge(com.grapecity.documents.excel.IRange,com.grapecity.documents.excel.AutoMergeDirection,com.grapecity.documents.excel.AutoMergeMode,com.grapecity.documents.excel.AutoMergeSelectionMode). The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIncludeAutoMergedCells(true);
boolean includeAutoMergedCells = options.getIncludeAutoMergedCells();
workbook.save("path/to/output.html", options);
true if automatically merged cells are included when exporting to HTML; otherwise, false.This option applies to auto-merge information added by IWorksheet.autoMerge(com.grapecity.documents.excel.IRange,com.grapecity.documents.excel.AutoMergeDirection,com.grapecity.documents.excel.AutoMergeMode,com.grapecity.documents.excel.AutoMergeSelectionMode). The default value is false.
HtmlSaveOptions options = new HtmlSaveOptions();
options.setIncludeAutoMergedCells(true);
workbook.save("path/to/output.html", options);
value - true if automatically merged cells are included when exporting to HTML; otherwise, false.The returned map uses CellAttribute values as keys and the corresponding HTML attribute names as values. You can use this map to inspect or modify which attributes are written to exported cell elements.
HtmlSaveOptions options = new HtmlSaveOptions();
Map<CellAttribute, String> cellAttributeOptions = options.getCellAttributeOptions();
cellAttributeOptions.put(CellAttribute.Address, "address");
workbook.save("path/to/output.html", options);
CellAttribute and the value is a string representing the attribute's name.Provide a map whose keys specify which CellAttribute values to export and whose values specify the HTML attribute names written to the exported cell elements. Set this property to null to clear the custom cell attribute mappings.
HtmlSaveOptions options = new HtmlSaveOptions();
Map<CellAttribute, String> cellAttributeOptions = new HashMap<>();
cellAttributeOptions.put(CellAttribute.Address, "data-address");
options.setCellAttributeOptions(cellAttributeOptions);
workbook.save("path/to/output.html", options);
value - A map where each key identifies a cell attribute to export and each value specifies the HTML attribute name to write for that attribute. null clears the custom cell attribute mappings.
getCssExportType()instead.