diff --git a/src/main.py b/src/main.py index 72a99f2..b14f270 100644 --- a/src/main.py +++ b/src/main.py @@ -75,6 +75,7 @@ def copy_excel_file(source_path, destination_path, passwords): # Create new sheet in destination workbook from openpyxl.chartsheet import Chartsheet if isinstance(source_sheet, Chartsheet): + chartsheet_warning = f"Chartsheet detected in '{os.path.basename(source_path)}' on sheet '{sheet_name}'." # For chartsheets, we need to create a worksheet instead dest_sheet = dest_wb.create_sheet(title=sheet_name) @@ -179,6 +180,8 @@ def copy_excel_file(source_path, destination_path, passwords): logging.info(f"Saved copied file to: {destination_path}") dest_wb.close() source_wb.close() + + return chartsheet_warning # Return the warning message if any chartsheets were found def remove_all_protection_tags(docx_path, output_path): logging.info(f"Processing Word document: {docx_path}") diff --git a/src/streamlit_app.py b/src/streamlit_app.py index 399d2c6..2ece62c 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -371,7 +371,9 @@ if input_method == "Upload Files" and uploaded_files and st.button("Process File temp_output_path = f"{temp_input_path}_processed" if file_type == "Excel": - copy_excel_file(temp_input_path, temp_output_path, passwords) + chartsheet_warning = copy_excel_file(temp_input_path, temp_output_path, passwords) + if chartsheet_warning: + st.warning(f"⚠️ {chartsheet_warning} Please check the processed file against the original to ensure data was copied correctly.") else: # Word remove_all_protection_tags(temp_input_path, temp_output_path) @@ -455,7 +457,9 @@ elif input_method == "Select Directory" and source_dir and dest_dir and st.butto os.makedirs(os.path.dirname(dest_path), exist_ok=True) if file_type == "Excel": - copy_excel_file(source_path, dest_path, passwords) + chartsheet_warning = copy_excel_file(source_path, dest_path, passwords) + if chartsheet_warning: + st.warning(f"⚠️ {chartsheet_warning} Please check the processed file against the original to ensure data was copied correctly.") else: # Word remove_all_protection_tags(source_path, dest_path)