pip install openpyxl
openpyxl-3.1.2-py2.py3-none-any.whl (249 kB)
et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
摘要:A Python library to read/write Excel 2010 xlsx/xlsm files
pip install pyqt5;
pip install pyqt5-tools;
编写 openpyxl_pyqt5.py 如下
# -*- coding: utf-8 -*-
import os
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox
from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem
from openpyxl import load_workbook
class ExcelReader(QMainWindow):
def __init__(self):
super().__init__()
# 设置窗口属性
self.setWindowTitle("Excel Reader")
self.setGeometry(100, 100, 800, 600)
# 选择.xlsx文件名
file_name, _ = QFileDialog.getOpenFileName(self, "Open Excel File", "", "xlsx Files (*.xlsx)")
if file_name:
self.file_path = file_name
else:
sys.exit(1)
if not os.path.exists(self.f

本文介绍了如何使用Python的openpyxl库配合PyQt5创建一个GUI应用程序,实现Excel文件的选择和数据读取,显示在QTableWidget中。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



