2023-06-09 17:35:27 +08:00

37 lines
1.2 KiB
Python

# -*- encoding: utf-8 -*-
import os
import sys
import excute
import json
import type_deal
import io
import os
current_file_path = os.path.split(os.path.realpath(__file__))[0]
site_packages_path = os.path.abspath(os.path.join(current_file_path, "../site-packages"))
sys.path.append(site_packages_path)
reload(sys)
from openpyxl import load_workbook
if __name__ == "__main__" :
av = sys.argv
tempPath = av[1]
xlsname = av[2]
wb = load_workbook(xlsname)
data = {}
for sheet in wb:
maxRow = sheet.max_row
maxColumn = sheet.max_column
for row in range(5, maxRow + 1):
data[sheet.cell(row, 1).value] = {}
t = data[sheet.cell(row, 1).value]
for column in range(2, maxColumn + 1):
key = sheet.cell(2, column).value
# print(type_deal.get_type_from_square(sheet.cell(4, column).value))
if key == "default" and sheet.cell(row, column).value != None:
v = str(sheet.cell(row, column).value)
t[sheet.cell(3, column).value] = type_deal.to_data(v)
break
wb.close()
open(tempPath, 'w').write(json.dumps(data))