1 Star 0 Fork 0

SpaceWorm/BuildExcel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.py 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
SpaceWorm 提交于 2021-06-29 10:36 . build project and add GUI file
from operator import le
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication,QTableWidgetItem
from bulidExcel import buildData
import json
class MainWindows:
def __init__(self):
# 从文件中加载UI定义
self.ui = uic.loadUi("TransformExcel.ui")
self.datas = {}
self.ui.previewBtn.clicked.connect(self.preViewData)
buildJson = '{"headNames":["aa","bb"],"load":false,"importData":false,"predefinedValue":[["aa","bb"],[],[],[],[]],"file":"c:\\\\data.xlsx","calcRules":[{"predefinedValue":[{"headName":"问题类型","valueRanges":["故事","任务"]}],"amount":1000}]}'
self.ui.buildText.setPlainText(json.dumps(json.loads(buildJson), indent=2,ensure_ascii=False))
def preViewData(self):
buildText = self.ui.buildText
self.datas = buildData(buildText.toPlainText())
if len(self.datas) > 0:
table = self.ui.dataTable
table.verticalHeader().setVisible(False)
table.setRowCount(len(self.datas)-1)
headNames = self.datas[0]
table.setColumnCount(len(headNames))
### 设置表头
for col in range(len(headNames)):
table.setHorizontalHeaderItem(col,QTableWidgetItem(headNames[col]))
### 设置数据
for row in range(len(self.datas)):
if row == 0:
continue
data = self.datas[row]
for col in range(len(data)):
item = QTableWidgetItem()
item.setText(data[col+1])
table.setItem(row,col,item)
app = QApplication([])
stats = MainWindows()
stats.ui.show()
app.exec_()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ztxhome/BuildExcel.git
git@gitee.com:ztxhome/BuildExcel.git
ztxhome
BuildExcel
BuildExcel
main

搜索帮助