我正在为一个项目将.xlsx报告表转换为.pdf格式。我想知道我是否可以无缝地携带选定的单元格,这些单元格中有粗体字,如下所示:
最后输出到这里的.pdf输出中,以尽可能保持一致性和易读性。以下是最终输出:
此外,我想知道我是否能够从不是Times New Roman的东西中更改最终.pdf输出中使用的整体字体,因为它不太适合行和列的性质
以下是我的脚本,作为帮助轻松集成的参考点:
import pandas as pd
import pdfkit
from datetime import datetime, date, time
import time
import os
from stat import S_IREAD, S_IRGRP, S_IROTH
import win32con, win32api, os
operating_system = 'Windows 10'
file_name = 'report_prototype_excel1.xlsx'
company_name = 'ABC Company'
audit_frequency = 'ANNUAL'
file_time = time.strftime("%d%m%Y-%H%M%S")
if operating_system == 'Windows 10':
config = pdfkit.configuration(wkhtmltopdf='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe')
elif operating_system == "Windows Server 2019":
print("Placeholder Windows Server 2019")
elif operating_system == "MacOS":
print("Placeholder MacOS")
else:
print("Placeholder Ubuntu/Debian")
df = pd.read_excel(file_name)
df = df.fillna(" ")
df.to_html("report_prototype_html1.html", index = False)
options = {
'page-size': 'A4',
'margin-top': '0.75in',
'margin-right': '0.75in',
'margin-bottom': '0.75in',
'margin-left': '0.75in',
}
generate_filename = company_name + '_' + audit_frequency + '_audit_report_pdf_' + file_time + '.pdf'
final_report = pdfkit.from_file("report_prototype_html1.html", generate_filename , configuration=config, options=options)
目前没有回答
相关问题 更多 >
编程相关推荐