KT25-1015_AC695x_SDK310/.codex_tmp/inspect_audio_requirements.py

37 lines
1.1 KiB
Python
Raw Normal View History

import json
import xlrd
path = r"E:\RD\Kaotings\KT25-1015_AC695x_SDK310\Doc\音频板开发需求 20260725.xls"
book = xlrd.open_workbook(path, formatting_info=True)
result = {"sheets": []}
for sheet in book.sheets():
rows = []
for r in range(sheet.nrows):
cells = []
for c in range(sheet.ncols):
value = sheet.cell_value(r, c)
if value not in ("", None):
cells.append({"cell": xlrd.formula.cellname(r, c), "value": value})
if cells:
rows.append(cells)
result["sheets"].append(
{
"name": sheet.name,
"nrows": sheet.nrows,
"ncols": sheet.ncols,
"merged": [
{
"range": (
f"{xlrd.formula.cellname(rlo, clo)}:"
f"{xlrd.formula.cellname(rhi - 1, chi - 1)}"
)
}
for rlo, rhi, clo, chi in sheet.merged_cells
],
"nonempty_rows": rows,
}
)
print(json.dumps(result, ensure_ascii=False, indent=2))