36 lines
1000 B
Python
36 lines
1000 B
Python
# -*- coding: utf-8 -*-
|
|
import sys, io, json
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
path = r"C:\Users\ruigu\Downloads\文档说明.html\20260826德国大众的要求文件\MAGSWITCH TECHNOLOGY EUROPE_CRA_Abfrage.xlsx"
|
|
|
|
try:
|
|
import openpyxl
|
|
except ImportError:
|
|
print("NO_OPENPYXL")
|
|
sys.exit(0)
|
|
|
|
wb = openpyxl.load_workbook(path, data_only=False)
|
|
print("SHEETS:", wb.sheetnames)
|
|
|
|
out = {}
|
|
for ws in wb.worksheets:
|
|
rows = []
|
|
for row in ws.iter_rows():
|
|
r = []
|
|
for c in row:
|
|
v = c.value
|
|
if v is None:
|
|
v = ""
|
|
r.append(str(v))
|
|
rows.append(r)
|
|
out[ws.title] = rows
|
|
print("==== SHEET:", ws.title, "dims:", ws.dimensions, "max_row:", ws.max_row, "max_col:", ws.max_column)
|
|
|
|
# dump full JSON to a file for reliable re-read
|
|
with open(r"d:\开发\OnebotCatalog\_xlsx_dump.json", "w", encoding="utf-8") as f:
|
|
json.dump(out, f, ensure_ascii=False, indent=1)
|
|
|
|
print("DUMP_DONE")
|