Generate printable Accelerated Reader book labels from an Excel spreadsheet.
Project description
ar-book-labels
English | 简体中文
Generate printable Accelerated Reader book labels from an Excel spreadsheet. Labels include book title, author, AR level (with standard color coding), points, and quiz number — formatted for sticker-style printing and sticking on books.
Features
- Standard AR color coding: 12 color ranges from yellow (0.1–1.5) to brown (6.6+)
- Print-ready HTML output: 4 columns x 9 rows = 36 labels per page, A4 size,
@pageCSS for direct printing - Smart text truncation: Titles wrap to 2 lines with ellipsis; authors on 1 line
- Author-first layout: Author name appears above title for easy shelf sorting
- Screen preview: SVG viewBox scaling for crisp browser preview
- Template included: Reference Excel template with sample data and column documentation
Installation
pip install ar-book-labels
Or install from source:
git clone https://github.com/TonyBlur/ar-book-labels.git
cd ar-book-labels
pip install -e .
Quick Start
- Get the template (optional — if you don't have an Excel file yet):
ar-book-labels --template
This copies ar_template.xlsx to your current directory. Fill it with your book data.
- Generate labels:
ar-book-labels books.xlsx -o labels.html
-
Open
labels.htmlin a browser to preview, then print (Ctrl/Cmd+P).Print tip: In the browser print dialog, choose "Actual size" (or "No margins" / "None" for margins) to prevent the browser from auto-adding page margins that shift label positions. The HTML already declares
@page { margin: 0 }; adding browser margins on top causes misalignment.
CLI Usage
ar-book-labels <excel> [options]
Arguments
| Argument | Description |
|---|---|
excel |
Path to the Excel file (.xlsx) |
Options
| Option | Default | Description |
|---|---|---|
-o, --output |
AR_Book_Labels.html |
Output HTML file path |
-s, --sheet |
first sheet | Sheet name to read (defaults to first sheet) |
--col-title |
AR Title |
Excel column name for book title |
--col-author |
AR Author |
Excel column name for author |
--col-level |
Book Level |
Excel column name for book level |
--col-points |
AR Points |
Excel column name for AR points |
--col-quiz |
Quiz Number |
Excel column name for quiz number |
--start-row |
2 |
1-indexed row where data begins (1 = header row) |
--scale |
1 |
Display scale factor for screen preview |
--bw |
— | Black-and-white mode: white circle with thin black outline, black level number |
--with-border |
— | Add a thin printable border around each label for manual cutting |
--template |
— | Copy the reference Excel template to cwd and exit |
-V, --version |
— | Show version and exit |
Examples
# Basic usage
ar-book-labels my_books.xlsx
# Custom output path and sheet name
ar-book-labels my_books.xlsx -o output/labels.html -s "Book Data"
# Custom column names (if your Excel uses different headers)
ar-book-labels my_books.xlsx --col-title "Title" --col-author "Author Name" --col-level "Level"
# Custom start row (e.g. data starts on row 3)
ar-book-labels my_books.xlsx --start-row 3
# With cutting-guide border (for manual label cutting)
ar-book-labels my_books.xlsx --with-border
# Black-and-white mode with border (ink-saving, for cutting)
ar-book-labels my_books.xlsx --bw --with-border
# Copy the template for reference
ar-book-labels --template
# Black-and-white mode for economical printing
ar-book-labels my_books.xlsx --bw
Excel Format
The spreadsheet must contain these columns (default names shown; use --col-* options to map custom names):
| Internal Key | Default Column | Type | Description |
|---|---|---|---|
title |
AR Title |
text | Book title |
author |
AR Author |
text | Author name |
level |
Book Level |
number | AR ATOS level (e.g. 5.1) |
points |
AR Points |
number | Points value |
quiz |
Quiz Number |
number/text | Quiz ID |
Rows with missing required fields are skipped with a warning printed to stderr.
Use ar-book-labels --template to get a pre-formatted template with sample data.
AR Level Color Chart
| Level Range | Color | Hex |
|---|---|---|
| 0.1 – 1.5 | Yellow | #FFD700 |
| 1.6 – 2.0 | Green | #2E8B57 |
| 2.1 – 2.5 | Dark Blue | #00008B |
| 2.6 – 3.0 | Red | #DC143C |
| 3.1 – 3.5 | Pink | #FF69B4 |
| 3.6 – 4.0 | Purple | #800080 |
| 4.1 – 4.5 | Orange | #FF8C00 |
| 4.6 – 5.0 | Light Blue | #00BFFF |
| 5.1 – 5.5 | Neon Orange | #FF6600 |
| 5.6 – 6.0 | Neon Green | #39FF14 |
| 6.1 – 6.5 | Black | #1C1C1C |
| 6.6+ | Brown | #8B4513 |
Development
Setup
git clone https://github.com/TonyBlur/ar-book-labels.git
cd ar-book-labels
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"
Project Structure
ar-book-labels/
ar_book_labels/
__init__.py # Package metadata and public API
generator.py # Core label generation logic
cli.py # CLI entry point (argparse)
__main__.py # python -m ar_book_labels support
templates/
ar_template.xlsx # Reference Excel template
tests/
test_generator.py # Unit tests
pyproject.toml # Build configuration (setuptools)
LICENSE # MIT License
README.md # This file (English)
README.zh.md # 中文文档
Running Tests
python -m pytest tests/ -v
Building & Publishing
pip install build twine
python -m build
twine check dist/*
twine upload dist/*
Automated Publishing (GitHub Actions)
This project uses a GitHub Actions workflow to automatically publish to PyPI when a new release is created:
- Bump the version in
pyproject.toml - Create a new release on GitHub (via the web UI or
gh release create) - The
publish.ymlworkflow will automatically build the package and publish it to PyPI using trusted publishing (OIDC — no API token needed)
Prerequisites: Configure a Trusted Publisher on PyPI for the ar-book-labels project, linking it to the TonyBlur/ar-book-labels repository and the pypi environment.
Code Style
- Python 3.8+
- No external dependencies beyond
openpyxl - Keep the generator logic self-contained and testable
License
MIT — see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ar_book_labels-0.1.3.tar.gz.
File metadata
- Download URL: ar_book_labels-0.1.3.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71e9d4c6231cd9fa3305f20bfc75edaa7911a6c149e454980f1a84d601cf9eca
|
|
| MD5 |
e17a3997e21e30d59193affd1125e7bf
|
|
| BLAKE2b-256 |
b42d942bd59ede7173893755f63c64b18f9919439dc2db4daed0b01edc1c04c0
|
Provenance
The following attestation bundles were made for ar_book_labels-0.1.3.tar.gz:
Publisher:
publish.yml on TonyBlur/ar-book-labels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ar_book_labels-0.1.3.tar.gz -
Subject digest:
71e9d4c6231cd9fa3305f20bfc75edaa7911a6c149e454980f1a84d601cf9eca - Sigstore transparency entry: 1935405619
- Sigstore integration time:
-
Permalink:
TonyBlur/ar-book-labels@915ead415a5cbbfe5f55fe82fca2b880f6387dc9 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/TonyBlur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@915ead415a5cbbfe5f55fe82fca2b880f6387dc9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ar_book_labels-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ar_book_labels-0.1.3-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b0d25317355096fe9d7b9be1dcb9c247e67123a93a888b41e2c9ce9eb5958c
|
|
| MD5 |
09b02112881028e36a4670744ba543ee
|
|
| BLAKE2b-256 |
25c9eacaece04194b978b6d0b10e063fcd965d2d0d3cef6184551b65bb1f6d03
|
Provenance
The following attestation bundles were made for ar_book_labels-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on TonyBlur/ar-book-labels
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ar_book_labels-0.1.3-py3-none-any.whl -
Subject digest:
e8b0d25317355096fe9d7b9be1dcb9c247e67123a93a888b41e2c9ce9eb5958c - Sigstore transparency entry: 1935405649
- Sigstore integration time:
-
Permalink:
TonyBlur/ar-book-labels@915ead415a5cbbfe5f55fe82fca2b880f6387dc9 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/TonyBlur
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@915ead415a5cbbfe5f55fe82fca2b880f6387dc9 -
Trigger Event:
release
-
Statement type: