Files

31 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
"""Dump .xls layout: row heights, col widths, print setup, print area, formulas."""
import sys
import xlrd
def dump(path):
print("=" * 90)
print("FILE:", path)
bk = xlrd.open_workbook(path, formatting_info=True)
try:
names = {k: (v.name, getattr(v, 'result', None)) for k, v in list(bk.name_map.items())}
print("NAMES:", names)
except Exception as e:
print("NAMES err", e)
for sh in bk.sheets():
print("-" * 90)
print("SHEET", sh.name, "nrows", sh.nrows, "ncols", sh.ncols)
print("defcolwidth", sh.defcolwidth, "standardwidth", getattr(sh, 'standardwidth', None))
print("colwidths:", [(c, sh.colinfo_map[c].width if c in sh.colinfo_map else None) for c in range(sh.ncols)])
print("rowheights:", [(r + 1, sh.rowinfo_map[r].height if r in sh.rowinfo_map else None) for r in range(sh.nrows)])
try:
pa = sh.phony_dim_rows
print("phony_dim_rows", pa)
except Exception:
pass
for attr in ("print_area", "print_titles"):
print(attr, getattr(bk, attr, None))
for p in sys.argv[1:]:
dump(p)