Create and Write on Excel File using xlsxwriter Module - Python Last Updated : 07 Apr, 2025 Comments Improve Suggest changes Like Article Like Report XlsxWriter The xlsxwriter module in Python is used to create Excel .xlsx files and write data into them. It supports:Writing text, numbers, and formulasCreating multiple worksheetsFormatting, charts, images, filters, and conditional formattingInstallationBefore using xlsxwriter, we need to install it using pip:pip install xlsxwriter Note:Rows and columns are zero-indexed. For example:Cell A1 - (0, 0)Cell B1 - (0, 1)Cell A2 - (1, 0)Examples of xlsxwriter moduleExample 1: Writing to Excel Using A1 NotationIn this example, we'll create a new Excel file and write simple text values to specific cells using the familiar A1-style cell notation: Python import xlsxwriter workbook = xlsxwriter.Workbook('path_to_hello.xlsx') worksheet = workbook.add_worksheet() worksheet.write('A1', 'Hello..') worksheet.write('B1', 'Geeks') worksheet.write('C1', 'For') worksheet.write('D1', 'Geeks') workbook.close() Output:Explanation:Workbook() creates a new Excel file.add_worksheet() adds a new worksheet to the workbook.write(cell, value) writes values to specific cells like 'A1', 'B1', etc.close() saves and closes the file.This creates a single worksheet with text in the first row from columns A to D.Example 2: Writing Using Row-Column IndexingThis example shows how to write a list of names to the first column using zero-based indexing (row, column) instead of A1-style cell notation: Python import xlsxwriter workbook = xlsxwriter.Workbook('example2.xlsx') worksheet = workbook.add_worksheet() content = ["ankit", "rahul", "priya", "harshita", "sumit", "neeraj", "shivam"] for row, name in enumerate(content): worksheet.write(row, 0, name) workbook.close() Output: Explanation:We loop through a list of names using enumerate() to get the row index.Each name is written to column 0 (i.e., column A), starting from row 0.Result: Each name appears in a new row under the first column. Example 3: Creating a Named Worksheet and Writing RowsHere, we create a custom-named worksheet and write a 2D list of names and scores into it row-by-row: Python import xlsxwriter workbook = xlsxwriter.Workbook('example3.xlsx') worksheet = workbook.add_worksheet("My Sheet") scores = [ ['ankit', 1000], ['rahul', 100], ['priya', 300], ['harshita', 50], ] for row, (name, score) in enumerate(scores): worksheet.write(row, 0, name) worksheet.write(row, 1, score) workbook.close() Output:Explanation:The worksheet is named "My Sheet" instead of the default "Sheet1".We write both names and their corresponding scores into two columns.Column A - NamesColumn B - ScoresThe data is written row-by-row using enumerate().Advantages of xlsxwriterSupports more Excel features than most other Python libraries.Produces files nearly identical to those created by Excel itself.Offers detailed documentation, examples, and testing support.Fast and memory-efficient, even for large files. LimitationsCannot read or modify existing Excel files.It is strictly a write-only library for .xlsx format. Comment More infoAdvertise with us Next Article Create and Write on Excel File using xlsxwriter Module - Python ankthon Follow Improve Article Tags : Python python-modules Practice Tags : python Similar Reads Python | Plotting an Excel chart with Gradient fills using XlsxWriter module Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations, and plotting graphs. Letâs see how to plot a chart with Gradient fills, using real-time data.Charts are compose 5 min read Python | Plotting bar charts in excel sheet using XlsxWriter module Prerequisite: Create and Write on an excel file.XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot different type of Bar charts using realtime data. Charts are composed 6 min read Python | Writing to an excel file using openpyxl module Prerequisite : Reading an excel file using openpyxl Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The openpyxl module allows Python program to read and modify Excel files. For example, user might have to go through thousands of rows and pick o 3 min read Python | Plotting Line charts in excel sheet using XlsxWriter module Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot Line charts using realtime data. Charts are composed of at least one 3 min read Python | Plotting Area charts in excel sheet using XlsxWriter module Prerequisite: Create and write on an excel file XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot different charts using realtime data. Charts are composed of at least 6 min read Python | Adding a Chartsheet in an excel sheet using XlsxWriter module XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations, and plotting graphs. Letâs see how to add a chartsheet to an excel sheet and plot a line chart on it, using real-time data. Charts are composed of at least one 3 min read Python | Plotting charts in excel sheet with Data Tools using XlsxWriter module | Set - 1 Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot charts with different types of Data Tools using realtime data. Charts 7 min read Python | Plotting charts in excel sheet with data tools using XlsxWriter module | Set â 2 Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot charts with different types of Data Tools using realtime data.Charts 7 min read Python | Plotting Pie charts in excel sheet using XlsxWriter module Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot different types of pie charts using realtime data. Charts are compos 5 min read Python | Plotting column charts in excel sheet using XlsxWriter module Prerequisite: Create and Write on an excel file.XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Letâs see how to plot different type of Column charts using realtime data. Charts are compo 6 min read Like