This is a Streamlit web application that compares two Excel files and generates a difference report. The report shows cells with differences between the two files and highlights them in yellow.
Make sure to install the following dependencies:
pip install pandas numpy streamlit openpyxl xlsxwriter
To run the Streamlit app, use the following command:
streamlit run streamlit_app.py
Then, open the provided URL in a web browser to start using the application.
- Upload the first Excel file (e.g., file1.xlsx) using the file uploader.
- Upload the second Excel file (e.g., file2.xlsx) using the second file uploader.
- The application will compare the files and display a summary of differences in the browser.
- You can download the difference report as an Excel file by clicking the "Download Report" button. Cells that are different will be highlighted and show the differences.
read_excel_file(file)
: Reads an Excel file and returns a pandas DataFrame.compare_dataframes(df1, df2)
: Compares two DataFrames and returns a DataFrame of the same shape withTrue
at the locations where the data differs andFalse
elsewhere.generate_report(df1, df2, diff_locations)
: Generates a difference report DataFrame with the formatcell_value_in_df2 -> cell_value_in_df1
for cells with differences.save_report(report, diff_locations, output_file)
: Saves the difference report to an Excel file with yellow background for cells with differences.
The Streamlit app is structured as follows:
- Set page configurations and display the title.
- Create file uploaders for both Excel files.
- If both files are uploaded, read them into DataFrames and compare them.
- Generate and display the difference report.
- Create a download button for the difference report as an Excel file.
- Delete the temporary file used for the download.