Convert a Document to Excel

Converting documents from one format to another is the flagship feature of Aspose.Words. You can convert documents in any available load format also to XLSX format.

Convert a Document to XLSX

Converting a document to XLSX is a rather complicated process. To save your document to XLSX format using Aspose.Words, use the XlsxSaveOptions class and the new Xlsx element in the SaveFormat enumeration. As mentioned above, you can save the document in any load format supported by Aspose.Words to XLSX.

The following code example shows how to save DOCX to XLSX:

Find and Replace When Saving to XLSX

Also using Aspose.Words, you can find a specific string or regular expression in your document and replace it with the matching one you need. Then you can also save the result to XLSX format.

The following code example shows how to perform find and replace operation and save result to XLSX:

Specify Compression Level When Saving to XLSX

You can also specify the compression level when saving using the CompressionLevel property.

The following code example shows how to specify the compression level when saving to XLSX format:

See Also


FAQ

  1. Q: Which document formats can be converted to Excel using Aspose.Words for Java?
    A: Aspose.Words can load any format listed in the LoadFormat enumeration (e.g., DOC, DOCX, RTF, HTML, ODT, EPUB, etc.). After loading, you can save the document to XLSX by using XlsxSaveOptions with the SaveFormat.XLSX option.

  2. Q: How do I perform a find‑and‑replace operation before saving to XLSX?
    A: Use the document’s Range to locate and replace text (e.g., doc.getRange().replace("old", "new", new FindReplaceOptions())). After the replacement, call document.save("output.xlsx", SaveFormat.XLSX) with optional XlsxSaveOptions.

  3. Q: How can I control the compression level of the generated XLSX file?
    A: Create an instance of XlsxSaveOptions and call setCompressionLevel (e.g., XlsxSaveOptions options = new XlsxSaveOptions(); options.setCompressionLevel(CompressionLevel.MAXIMUM);). Pass this options object to document.save.

  4. Q: Do I need a license to use the conversion features?
    A: Not to use the feature. Without a license, Aspose.Words for Java works in evaluation mode with full functionality, but it adds an evaluation watermark and limits the document size to a few hundred paragraphs. To remove these limitations, apply a license: License license = new License(); license.setLicense("Aspose.Words.Java.lic");.