def on_importXLSX_clicked(self):
fileName, _ = QFileDialog.getOpenFileName(self, 'Open file...', self.env, "Microsoft Office Excel(*.xlsx *.xlsm *.xltx *.xltm)")
if fileName:
wb = openpyxl.load_workbook(fileName)
ws = wb.get_sheet_by_name(wb.get_sheet_names()[0])
data = list()
i = 1
while True:
x = ws.cell(row=i, column=1).value
y = ws.cell(row=i, column=2).value
if x==None or y==None:
break
try:
data.append((round(float(x), 4), round(float(y), 4)))
except:
dlgbox = QMessageBox(QMessageBox.Warning, "File error", "Wrong format.\nThe datasheet seems to including non-digital cell.", (QMessageBox.Ok), self)
if dlgbox.exec_():
break
i += 1
for e in data:
self.on_add_clicked(e[0], e[1])
评论列表
文章目录