将表格小部件导出为Excel文件时出现问题

时间:2019-01-03 11:46:05

标签: pyqt5

我需要将表格小部件(包括标题)导出为ex​​cel文件,但收到错误消息:

pad / ffill: propagate last valid observation forward to next valid

我已经实现了两个文件:一个用于GUI >> Int_PX_1,另一个包含导出功能>> Functions_PX_1

这里是Int_PX_1调用函数:

File "/Users/manuelzompetta/OneDrive/Programmazione/PycharmProjects/ProjectX/Int_PX_1.py", line 434, in tb1_2_Export2
    Func_PX_1.save_wtable_to_xls(self.table_View_1, filename)
  File "/Users/manuelzompetta/OneDrive/Programmazione/PycharmProjects/ProjectX/Func_PX_1.py", line 94, in save_wtable_to_xls
    sheet.write(r + 1, c + 1, text)
  File "/Users/manuelzompetta/.conda/envs/PycharmProjects/lib/python3.6/site-packages/xlwt/Worksheet.py", line 1088, in write
    self.row(r).write(c, label, style)
  File "/Users/manuelzompetta/.conda/envs/PycharmProjects/lib/python3.6/site-packages/xlwt/Row.py", line 260, in write
    raise Exception("Unexpected data type %r" % type(label))
Exception: Unexpected data type <class 'PyQt5.QtCore.QVariant'>

这是导出功能:

@pyqtSlot()
def tb1_2_Export2(self):
    options = QFileDialog.Options()
    options |= QFileDialog.DontUseNativeDialog
    filename, _ = QFileDialog.getSaveFileName(self, "Esporta Analisi", "Output.xlsx",
                                              "Excel Files (*.xlsx)", options=options)
    Func_PX_1.save_wtable_to_xls(self.table_View_1, filename)

    print('tb21_Export2')

我该如何解决这个问题?

0 个答案:

没有答案