manabb commited on
Commit
334211b
·
verified ·
1 Parent(s): 14a7033

Update manabCQgenetaion.py

Browse files
Files changed (1) hide show
  1. manabCQgenetaion.py +22 -0
manabCQgenetaion.py CHANGED
@@ -7,6 +7,11 @@ import os
7
  import re
8
  import pandas as pd
9
 
 
 
 
 
 
10
  def normalize_text(s: str) -> str:
11
  """Normalize whitespace / newlines in page_content."""
12
  s = s.replace("\r\n", "\n").replace("\r", "\n")
@@ -143,6 +148,23 @@ def compliance_import_OEM(manabfile: str, client):
143
  classes='table table-striped table-bordered table-hover',
144
  table_id='extraction-table'
145
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  compliance_html = compliance_df.to_html(
147
  index=False,
148
  escape=False,
 
7
  import re
8
  import pandas as pd
9
 
10
+ import io
11
+ from flask import send_file
12
+
13
+
14
+
15
  def normalize_text(s: str) -> str:
16
  """Normalize whitespace / newlines in page_content."""
17
  s = s.replace("\r\n", "\n").replace("\r", "\n")
 
148
  classes='table table-striped table-bordered table-hover',
149
  table_id='extraction-table'
150
  )
151
+ @app.route("/download-extraction")
152
+ def download_extraction():
153
+ output = io.BytesIO()
154
+ with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
155
+ extraction_df.to_excel(writer, index=False, sheet_name="Extraction")
156
+ output.seek(0)
157
+ return send_file(
158
+ output,
159
+ as_attachment=True,
160
+ download_name="extraction.xlsx", # Flask >= 2.0
161
+ mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
162
+ )
163
+ extraction_html+=f"""
164
+ <a href="/download-extraction" class="btn btn-primary" download>
165
+ Download as Excel
166
+ </a>
167
+ """
168
  compliance_html = compliance_df.to_html(
169
  index=False,
170
  escape=False,