Metadata-Version: 2.4
Name: xlsx2dict
Version: 0.1.2
Summary: A python library for reading and writing Excel files, converting between xlsx and dict or text
Project-URL: Repository, https://github.com/huanghhhz/xlsx2dict
Author-email: hhhpy <huanghuanhuanhdu@gmail.com>
License: MIT
License-File: LICENSE
Keywords: cli,convert,dict,excel,spreadsheet,xlsx
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Requires-Dist: python-calamine
Requires-Dist: tabulate
Requires-Dist: xlsxwriter
Description-Content-Type: text/markdown

# xlsx2dict

A Python library for reading and writing Excel files, converting between xlsx and dict or text.

## Installation

```bash
pip install xlsx2dict
```

## Usage

### Python API

```python
from xlsx2dict import sheets, read, read_dict, write, write_dict, xlsx2text

# List sheet names
sheet_names = sheets("example.xlsx")

# Read a sheet as list of lists
data = read("example.xlsx", sheet_name="Sheet1")

# Read a sheet as ordered dict (keyed by row number)
d = read_dict("example.xlsx", sheet_name="Sheet1")
d = read_dict("example.xlsx", sheet_name="Sheet1", head_rows=2)       # multi-row headers
d = read_dict("example.xlsx", sheet_name="Sheet1", save_list=True)    # include raw row as __list__
d = read_dict("example.xlsx", sheet_name="Sheet1", key_map={"Old": "New"})  # rename columns

# Write list of lists to xlsx
write([["Name", "Age"], ["Alice", 30]], "output.xlsx", sheet_name="Data")

# Write dict to multi-sheet xlsx
write_dict("output.xlsx", {
    "Sheet1": [["Name", "Age"], ["Alice", 30]],
    "Sheet2": [["City", "Country"], ["Paris", "France"]],
})

# Convert xlsx to formatted text
xlsx2text("example.xlsx")                    # prints all sheets
xlsx2text("example.xlsx", index=1)           # prints first sheet
xlsx2text("example.xlsx", output_file="out.txt")  # write to file
```

### CLI

```bash
# Convert all sheets to console
xlsx2text example.xlsx

# Convert a specific sheet
xlsx2text example.xlsx -i 1

# Save output to file
xlsx2text example.xlsx -o output.txt
```

## License

MIT
