# python-scipyHow do I use Python XlsxWriter to write a NumPy array to an Excel file?

Using Python XlsxWriter, you can write a NumPy array to an Excel file. Here is an example of how to do this:

```
import xlsxwriter
import numpy as np
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('arrays.xlsx')
worksheet = workbook.add_worksheet()
# Create an array of numbers
data = np.arange(1, 65).reshape(8, 8)
# Write the array to the worksheet.
worksheet.write_array('A1', data)
# Close the workbook.
workbook.close()
```

This code will create an Excel file named 'arrays.xlsx' with the NumPy array written to it.

The code consists of the following parts:

- Importing the xlsxwriter and numpy libraries.
- Creating a workbook and worksheet.
- Creating an array of numbers using the numpy library.
- Writing the array to the worksheet.
- Closing the workbook.

## Helpful links

### More of Python Scipy

- How do I create a 2D array of zeros using Python and NumPy?
- How do I use the scipy ttest_ind function in Python?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How can I use Python Numpy to select elements from an array based on multiple conditions?
- How do I use Python and SciPy to create a tutorial PDF?
- How can I use Python and SciPy to implement a quantum Monte Carlo simulation?
- How do I use the numpy vstack function in Python?
- How can I use Python and SciPy to solve an ordinary differential equation?
- How do I create a zero matrix using Python and Numpy?

See more codes...