AO, cit, itat report download code commit.

This commit is contained in:
2025-12-02 00:36:46 +05:30
parent 7cf8287b34
commit d21daaa83f
11 changed files with 301 additions and 103 deletions

View File

@@ -1,6 +1,8 @@
# AppCode/ITATHandler.py
from AppCode.Config import DBConfig
from AppCode.Config import DBConfig
import mysql.connector
import pandas as pd
import io
class ITATHandler:
@@ -59,7 +61,34 @@ class ITATHandler:
self.conn.commit()
# CLOSE CONNECTION
def itat_report_download(self, selected_year):
try:
# Call stored procedure
self.cursor.callproc("GetITATByYear", [selected_year])
rows = []
for result in self.cursor.stored_results():
rows = result.fetchall()
if not rows:
return None
df = pd.DataFrame(rows)
# Excel output
output = io.BytesIO()
with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
df.T.to_excel(writer, header=False, sheet_name="ITAT_Report")
output.seek(0)
return output
except mysql.connector.Error as e:
print("MySQL Error:", e)
return None
# CLOSE CONNECTION
def close(self):
self.cursor.close()
self.conn.close()