Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -151,27 +151,27 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, output_pdf_path):
|
|
151 |
|
152 |
def add_table(self, dataframe):
|
153 |
self.set_font('Arial', 'B', 10)
|
154 |
-
|
155 |
-
row_height = self.font_size
|
156 |
|
157 |
# Adiciona os cabe莽alhos
|
158 |
-
for
|
159 |
-
self.
|
160 |
-
self.ln(row_height)
|
161 |
|
162 |
# Adiciona os dados com quebras de p谩gina
|
163 |
self.set_font('Arial', '', 10)
|
164 |
for row in dataframe.itertuples(index=False):
|
165 |
-
|
|
|
|
|
|
|
166 |
self.add_page()
|
167 |
self.set_font('Arial', 'B', 10)
|
168 |
-
for
|
169 |
-
self.
|
170 |
-
self.ln(row_height)
|
171 |
self.set_font('Arial', '', 10)
|
172 |
-
for i, item in enumerate(row):
|
173 |
-
self.multi_cell(col_widths[i], row_height, str(item), border=1, align='C')
|
174 |
-
self.ln(row_height)
|
175 |
|
176 |
def add_image(self, image_path):
|
177 |
self.add_page()
|
@@ -294,21 +294,13 @@ with gr.Blocks(theme=theme) as interface:
|
|
294 |
|
295 |
generate_btn = gr.Button("Gerar Relat贸rio", variant="primary") # Destaque no bot茫o
|
296 |
output_html = gr.HTML()
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
with gr.Row(): # Crie uma nova linha para os bot玫es
|
301 |
-
download_html_btn = gr.Button("Baixar Relat贸rio HTML")
|
302 |
-
download_pdf_btn = gr.Button("Baixar Relat贸rio PDF")
|
303 |
|
304 |
def wrapper(html_file, excel_files):
|
305 |
html_content, html_path, pdf_path = processar_relatorio(html_file, excel_files)
|
306 |
return html_content, html_path, pdf_path
|
307 |
|
308 |
-
generate_btn.click(
|
309 |
-
fn=wrapper,
|
310 |
-
inputs=[html_file, excel_files],
|
311 |
-
outputs=[output_html, download_html, download_pdf]
|
312 |
-
)
|
313 |
|
314 |
interface.launch()
|
|
|
151 |
|
152 |
def add_table(self, dataframe):
|
153 |
self.set_font('Arial', 'B', 10)
|
154 |
+
col_width = self.w / len(dataframe.columns)
|
155 |
+
row_height = self.font_size
|
156 |
|
157 |
# Adiciona os cabe莽alhos
|
158 |
+
for col in dataframe.columns:
|
159 |
+
self.cell(col_width, row_height * 2, col, border=1)
|
160 |
+
self.ln(row_height * 2)
|
161 |
|
162 |
# Adiciona os dados com quebras de p谩gina
|
163 |
self.set_font('Arial', '', 10)
|
164 |
for row in dataframe.itertuples(index=False):
|
165 |
+
for item in row:
|
166 |
+
self.cell(col_width, row_height * 2, str(item), border=1)
|
167 |
+
self.ln(row_height * 2)
|
168 |
+
if self.get_y() > self.page_break_trigger - 2 * row_height:
|
169 |
self.add_page()
|
170 |
self.set_font('Arial', 'B', 10)
|
171 |
+
for col in dataframe.columns:
|
172 |
+
self.cell(col_width, row_height * 2, col, border=1)
|
173 |
+
self.ln(row_height * 2)
|
174 |
self.set_font('Arial', '', 10)
|
|
|
|
|
|
|
175 |
|
176 |
def add_image(self, image_path):
|
177 |
self.add_page()
|
|
|
294 |
|
295 |
generate_btn = gr.Button("Gerar Relat贸rio", variant="primary") # Destaque no bot茫o
|
296 |
output_html = gr.HTML()
|
297 |
+
download_html_btn = gr.File(label="Download HTML Report")
|
298 |
+
download_pdf_btn = gr.File(label="Download PDF Report")
|
|
|
|
|
|
|
|
|
299 |
|
300 |
def wrapper(html_file, excel_files):
|
301 |
html_content, html_path, pdf_path = processar_relatorio(html_file, excel_files)
|
302 |
return html_content, html_path, pdf_path
|
303 |
|
304 |
+
generate_btn.click(fn=wrapper, inputs=[html_file, excel_files], outputs=[output_html, download_html_btn, download_pdf_btn])
|
|
|
|
|
|
|
|
|
305 |
|
306 |
interface.launch()
|