Convert to Spreadsheet with advanced options

GroupDocs.Conversion provides the SpreadsheetConvertOptions class, allowing fine-grained control over the conversion process when converting documents to spreadsheet formats. This class extends the common conversion options available in the base class and introduces additional configuration parameters for enhanced flexibility:

OptionDescription
setFormat()Specifies the desired output format. Supported formats include Xls, Xlsx, Xlsm, Xlsb, Ods, Ots, Xltx, Xlt, Xltm, Tsc, Xlam, and Csv.
setPassword()Enables password protection for the converted file, using the specified password for securing the document.
setZoom()Sets the zoom level of the resulting document, defined as a percentage.

The code snippet below demonstrates how to configure and execute a document conversion to a spreadsheet format using advanced options. In this example, only a specific page from the input document is converted, and additional parameters such as format and zoom level are defined:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.filetypes.SpreadsheetFileType;
import com.groupdocs.conversion.options.convert.SpreadsheetConvertOptions;

public class ConvertToSpreadsheetWithAdvancedOptions {
    public static void convert() {
        // Load the source document
        try(Converter converter = new Converter("formatting.docx")) {
            // Set conversion options for spreadsheets
            SpreadsheetConvertOptions options = new SpreadsheetConvertOptions();
            options.setPageNumber(2);            // Convert only the second page
            options.setPagesCount(1);            // Limit to a single page
            options.setFormat(SpreadsheetFileType.Xls);    // Output format
            options.setZoom(50);                // Set zoom level to 50%

            // Perform the conversion
            converter.convert("converted_with_options.xls", options);
        }
    }

    public static void main(String[] args){
        convert();
    }
}

formatting.docx is sample file used in this example. Click here to download it.

converted_with_options.xls is converted XLS document. Click here to download it.

This flexibility enables tailored conversion workflows, ensuring the output meets specific requirements such as format compatibility, content accessibility, or security constraints.