qq1023 commited on
Commit
7d516bd
·
1 Parent(s): 8f53f52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -267,10 +267,13 @@ def process_and_output_files(input_files):
267
 
268
  df = pd.DataFrame(string_data)
269
 
270
- table_html = df.to_html(classes="table table-bordered", index=False)
 
271
 
 
272
  scrollable_table = f'<div style="overflow-x: auto;">{table_html}</div>'
273
- return scrollable_table
 
274
 
275
  #return data
276
 
@@ -370,7 +373,9 @@ with gr.Blocks(title="Automatic Reimbursement Tool Demo") as page:
370
  height=240,
371
  )
372
  #information = gr.JSON(label="Extracted information")
373
- information = gr.HTML()
 
 
374
 
375
  with gr.Row():
376
  flag_incorrect_button = gr.Button(
@@ -400,11 +405,11 @@ with gr.Blocks(title="Automatic Reimbursement Tool Demo") as page:
400
  submit_button.click(
401
  clear_outputs,
402
  [input_file],
403
- [extracted_text, category, chatbot, information],
404
  ).then(
405
  process_and_output_files,
406
  [input_file],
407
- [information],
408
  ).then(
409
  flag_if_shared(flag_method),
410
  [
 
267
 
268
  df = pd.DataFrame(string_data)
269
 
270
+ filename = "output.xlsx"
271
+ df.to_excel(filename, index=False)
272
 
273
+ table_html = df.to_html(classes="table table-bordered", index=True)
274
  scrollable_table = f'<div style="overflow-x: auto;">{table_html}</div>'
275
+
276
+ return scrollable_table, filename
277
 
278
  #return data
279
 
 
373
  height=240,
374
  )
375
  #information = gr.JSON(label="Extracted information")
376
+ table_display = gr.HTML(label="Table Display")
377
+ excel_download = gr.File(label="Download Excel", type="file")
378
+
379
 
380
  with gr.Row():
381
  flag_incorrect_button = gr.Button(
 
405
  submit_button.click(
406
  clear_outputs,
407
  [input_file],
408
+ [extracted_text, category, chatbot, table_display],
409
  ).then(
410
  process_and_output_files,
411
  [input_file],
412
+ [table_display, excel_download], # Adding excel_download here
413
  ).then(
414
  flag_if_shared(flag_method),
415
  [