0

I'm practicing a program that reads and displays Excel files Try raising the entire code. I'm using Python 3.9, Pycharm PyQt5 - 5.15.7 Help me TT

import sys from PyQt5.QtWidgets import QApplication, QWidget, QTableWidget, QTableWidgetItem, QHeaderView, QHBoxLayout, QVBoxLayout, QPushButton from PyQt5.QtCore import Qt import pandas as pd from pympler import muppy all_objects = muppy.get_objects()

class MyApp(QWidget): def init(self): super().init() self.window_width, self.window_height = 700, 500 self.resize(self.window_width, self.window_height)

    layout = QVBoxLayout()
    self.setLayout(layout)

    self.table = QTableWidget()
    layout.addWidget(self.table)

    self.button = QPushButton('&load Data')
    self.button.clicked.connect(lambda _, xl_path=excel_file_patch, sheet_name=worksheet_name: self.loadExcelData(xl_path, sheet_name))
    layout.addWidget(self.button)

def loadExcelData(self, excel_file_dir, worksheet_name):
    df = pd.read_excel(excel_file_dir, worksheet_name)
    if df.size == 0:
        return super.loadExcelData(excel_file_dir, worksheet_name)

    df.fillna('', inplace=True)
    self.table.setRowCount(df.shape[0])
    self.table.setColumnCount(df.shape[0])
    self.table.setHorizontalHeaderLabels(df.columns)

if name == 'main':

excel_file_patch = 'data.xlsx'
worksheet_name = 'Sales'

app = QApplication(sys.argv)
myApp = MyApp()
myApp.show()

try:
    sys.exit(app.exec())
except SystemExit:
    print('closing Window...')
김동주
  • 1
  • 1
  • Does this answer your question? [Why does PyQt crashes without information? (exit code 0xC0000409)](https://stackoverflow.com/questions/46710299/why-does-pyqt-crashes-without-information-exit-code-0xc0000409) – ewokx Jul 06 '22 at 06:53
  • Please [edit] your question and ensure that you're properly [formatting code](https://meta.stackoverflow.com/a/251362), and check the syntax in the post preview before submitting. – musicamante Jul 06 '22 at 10:11

0 Answers0