This is the first one of a new serie of articles about the interaction between Python and Excel.
Learn to use Excel with Python
It’s a good thing to use Python to accelerate our work with Excel. Python is very easy to learn, it has the most beautiful syntax in the world of scripting /programming languages and so, let’s learn how to use it to manipulate Excel data.
Installing XslxWriter
First of all let’s install the module XlsxWriter that enable us to interact with Escel through Python, right?
pip install XlsxWriter
Create a new Excel file with Python
After you installed the XlsxWriter module, you are ready to create your Excel files with the data you need.
You will follow this process:
- import the module
- create a Workbook
- create a worksheet
- add a value to a cell
- close the Workbook
You can read the code here and in the video below.
The code to create an Excel file and add a value
import xlsxwriter import os wb = xlsxwriter.Workbook("Excel1.xlsx") ws = wb.add_worksheet() ws.write("A1", 150) wb.close() os.system("Excel1.xlsx")
The video tutorial to use Excel