支持两种学生名单

This commit is contained in:
2025-06-04 22:16:46 +08:00
parent a2250d25cf
commit 4517a06eff
3 changed files with 27 additions and 14 deletions

View File

@@ -56,23 +56,23 @@ class DTGWorker(QObject):
if os.path.exists(pdf_file):
os.remove(pdf_file)
pythoncom.CoInitialize()
# https://stackoverflow.com/questions/71292585/python-docx2pdf-attributeerror-open-saveas
word = client.Dispatch("Word.Application", pythoncom.CoInitialize())
word = client.Dispatch("Word.Application")
doc = word.Documents.Open(word_file)
try:
doc = word.Documents.Open(word_file)
doc.SaveAs(pdf_file, 17)
doc.Close()
os.remove(word_file)
os.startfile(pdf_file)
except Exception as e:
raise Exception("PDF转换失败但Word文档已生成") from e
finally:
doc.Close()
word.Quit()
elif self.output_type == 'word':
os.startfile(word_file)
except Exception as e:
self.error.emit("😢 不好出错了", e)
except Exception:
self.error.emit("😢 不好出错了", traceback.format_exc())
self.progress[int].emit(-1)
finally:
self.finished.emit()