
While Parquet is the fastest format, the business world runs on Excel. Polars read Excel Via a read_excel function to load these files directly into a high-performance DataFrame.
Step 1: Installation
Polars needs an “engine” to read .xlsx files. You can use openpyxl or xlsx2csv.
pip install polars openpyxl
Step 2: Reading the Excel File
The pl.read_excel() function works just like pd.read_excel.
import polars as pl
# 1. Read the file
# Polars automatically uses the 'openpyxl' engine
df = pl.read_excel("my_report.xlsx")
print(df.head())Advanced Options
Excel files are tricky. They often have multiple sheets or headers in the wrong place.
1. Specifying a Sheet
sheet_name="Sheet2"(by name)sheet_id=1(by index, where 1 is the first sheet)
# Read the second sheet in the workbook
df_sales = pl.read_excel("my_report.xlsx", sheet_id=2)2. Skipping Rows (Bad Headers)
If your real header is on row 3, you can use read_csv‘s “skip” logic inside the read_excel_options.
# This tells the 'xlsx2csv' engine to skip the first 2 rows
df_clean = pl.read_excel(
"my_report.xlsx",
read_excel_options={"skip_rows": 2}
)This gives you the power of Polars while still being able to work with legacy Excel files.
Key Takeaways
- Polars offers a `read_excel` function to load Excel files into high-performance DataFrames.
- You need an engine like `openpyxl` or `xlsx2csv` for Polars to read `.xlsx` files.
- The `pl.read_excel()` function operates similarly to `pd.read_excel`, making it user-friendly.
- You can specify sheets by name or index, and handle tricky headers by skipping rows as needed.
- Using Polars allows you to manage legacy Excel files effectively.





