---
title: "Convert Word to Excel in Python"
---


{{% alert color="grey" %}}
*Purpose Summary. What is this page about?*

This page shows how to use Aspose.Words for Python via .NET to convert documents of any supported format to XLSX, including examples of basic conversion, find‑and‑replace before saving, and configuring compression with `XlsxSaveOptions`.

{{% /alert %}}

Converting documents from one format to another is the flagship feature of Aspose.Words. You can convert documents in any available [load format](https://reference.aspose.com/words/python-net/aspose.words/loadformat/) 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](https://reference.aspose.com/words/python-net/aspose.words.saving/xlsxsaveoptions/) class and the new `Xlsx` element in the [SaveFormat](https://reference.aspose.com/words/python-net/aspose.words/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 PDF to XLSX:

{{< highlight python >}}
doc = aw.Document(docs_base.my_dir + "Pdf Document.pdf")

doc.save(docs_base.artifacts_dir + "BaseConversions.PdfToXlsx.xlsx")
{{< /highlight >}}

{{% alert color="primary" %}}

Sometimes it is necessary to specify additional options, which can affect the result of saving a document as a XLSX. These options can be specified using the [XlsxSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/xlsxsaveoptions/) class, containing properties that determine how the XLSX output will be displayed.

{{% /alert %}}

## 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:

{{< highlight python >}}
from aspose.words import Document, DocumentBuilder
from aspose.words.replacing import FindReplaceOptions

doc =  Document()

builder = DocumentBuilder(doc)
builder.writeln("Ruby bought a ruby necklace.")

# We can use a "FindReplaceOptions" object to modify the find - and -replace process.
options = FindReplaceOptions()

# Set the "match_case" flag to "True" to apply case sensitivity while finding strings to replace.
# Set the "match_case" flag to "False" to ignore character case while searching for text to replace.
options.match_case = True

doc.range.replace("Ruby", "Jade", options)
doc.save(ARTIFACTS_DIR + "BaseConversions.FindReplaceXlsx.xlsx")
{{< /highlight >}}

## Specify Compression Level When Saving to XLSX

You can also specify the compression level when saving using the [CompressionLevel](https://reference.aspose.com/words/python-net/aspose.words.saving/xlsxsaveoptions/compression_level/) property.

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

{{< highlight python >}}
from aspose.words import Document
from aspose.words.saving import XlsxSaveOptions, CompressionLevel

doc = Document(MY_DIR + "Document.docx")

saveOptions = XlsxSaveOptions()
saveOptions.compression_level = CompressionLevel.MAXIMUM

doc.save(ARTIFACTS_DIR + "BaseConversions.CompressXlsx.xlsx", saveOptions)
{{< /highlight >}}

## See Also

- Documentation section [Protect or Encrypt a Document](/words/python-net/protect-or-encrypt-a-document/) for more information about protecting and encrypting a document
- The article [Find and Replace](/words/python-net/find-and-replace/) for more more information about finding and replacing the content you want

------ 

## FAQ

1. **Q:** How do I convert a PDF file to XLSX using Aspose.Words for Python?  
   **A:** Load the PDF with `Document`, then call `save` specifying an XLSX file name. Aspose.Words automatically converts the PDF content to an Excel workbook.

2. **Q:** Which source document formats can be saved as XLSX?  
   **A:** Any format that Aspose.Words can load — such as DOC, DOCX, RTF, HTML, PDF, ODT, and more — can be saved directly to XLSX using the same `save` method.

3. **Q:** How can I control the compression of the generated XLSX file?  
   **A:** Create an `XlsxSaveOptions` instance, set its `compression_level` property (e.g., `CompressionLevel.MAXIMUM`), and pass the options object to `Document.save`.

4. **Q:** Can I perform find‑and‑replace operations before converting to XLSX?  
   **A:** Yes. Use `Document.range.replace` (optionally with a `FindReplaceOptions` object) to modify the document, then save the updated document to XLSX.

5. **Q:** Is a license required to convert documents to XLSX?  
   **A:** A valid Aspose.Words license removes evaluation watermarks and enables full functionality, including conversion to XLSX. Without a license, the conversion works but the output will contain evaluation notices.