Console/terminal sample for reading and writing Excel workbooks with openpyxl, supporting Windows 11 and Ubuntu Linux 24.04. Step 03 reads the example workbook (sheets, cells, rows and columns, cell ranges, column-letter helpers) and saves the sheet as a matplotlib table PNG; step 04 writes three workbooks, demonstrating sheet create/remove, fonts, alignment, column widths and row heights, a formula and append, and loading an existing file before appending one row.

 

Data-Read-Write-Excel-inference-Jupyter.png

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • data/excel/stock-data.xlsx: example workbook, sheet name stock-data.
  • model/excel/: outputs, output.xlsx, output2.xlsx, output3.xlsx plus the table image {name}_table.png.
  • tool/tools.py: shared helpers.
  • src/: source code, launcher scripts and this document.
  • venv/: Python virtual environment, created by step 01.

[Instructions]

1. 01_venv_create.bat / 01_venv_create.sh

Delete the old venv/, create a fresh one and install src/requirements.txt. Aborts loudly if pip fails.

 

2. 02_venv_activate.bat / 02_venv_activate.sh

Activate the virtual environment. On Linux use source src/02_venv_activate.sh.

 

3. 03_read_excel.bat / 03_read_excel.sh

Run all the Excel reading demonstrations and save the table PNG to model/excel/.

 

4. 04_write_excel.bat / 04_write_excel.sh

Write output.xlsx, output2.xlsx and output3.xlsx to model/excel/.

 

5. 99_venv_clear.bat / 99_venv_clear.sh

Delete the venv/ folder.

 

[Python Entry Points]

src/read_excel.py

  • --input data/excel/stock-data.xlsx: path to the input workbook
  • --output model/excel/{name}_table.png: path of the output table image
  • --show: also open a window showing the table (optional)

Demonstrates: listing sheet names, reading cell values, iterating rows and columns, taking a single column or row, converting between column letters and indexes with get_column_letter and column_index_from_string, reading the A1:E2 range, and finally saving the table figure.

 

src/write_excel.py

  • --input data/excel/stock-data.xlsx: path to the input workbook
  • --output-dir model/excel: folder for the output files

Writes three files: output.xlsx (create and remove sheets), output2.xlsx (Font, Alignment, column widths and row heights, the =A2-B2 formula, append), and output3.xlsx (load an existing file and append one row).

 

[Quick Start]

Windows 11

src\01_venv_create.bat

src\03_read_excel.bat

src\04_write_excel.bat

 

Ubuntu Linux 24.04

bash src/01_venv_create.sh

bash src/03_read_excel.sh

bash src/04_write_excel.sh

 

Point --input at your own workbook, for example: src\03_read_excel.bat --input path\to\book.xlsx

 

[References]

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.