DiffXcel is a lightweight web application built with Flask that allows you to easily compare two Excel files (.xlsx format) and visualize the differences. It generates a clear, interactive HTML report highlighting changes between sheets and cells.
- Excel Comparison: Upload two Excel files, and DiffXcel will compare them sheet by sheet.
- Detailed HTML Reports: Generates an intuitive HTML report showing:
- Sheets present only in the original file.
- Sheets present only in the modified file.
- Side-by-side differences for common sheets, highlighting added, changed, and deleted rows/cells.
- Downloadable Reports: You can download the generated HTML report for offline viewing or sharing.
- User-Friendly Interface: A simple and clean web interface for uploading files and viewing reports.
- Secure File Handling: Uses
werkzeug.utils.secure_filenameto prevent directory traversal vulnerabilities and enforces a file size limit.
DiffXcel leverages the openpyxl library to read Excel files and difflib.HtmlDiff to generate the visual differences. Each sheet is converted into a list of tab-separated lines, allowing HtmlDiff to effectively compare their contents. The application then aggregates these differences into a single, comprehensive HTML report.
A visual representation of DiffXCel in action, showcasing a clear, color-coded comparison report.
Follow these steps to set up and run DiffXcel locally.
Before you begin, ensure you have the following installed:
- Python 3.x: Download from python.org.
- pip: Python's package installer (usually comes with Python).
-
Clone the repository:
git clone https://github.com/sonnylaskar/DiffXcel.git cd DiffXcel -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
If you don't have a
requirements.txtfile, you can create one with:pip install Flask openpyxl beautifulsoup4 pip freeze > requirements.txt
Once you have installed the dependencies, you can run the Flask application:
python app.pyThe application will typically run on http://127.0.0.1:5000/. Open this URL in your web browser.
- Open the Application: Navigate to
http://127.0.0.1:5000/in your web browser. - Upload Files: You will see a form with two file input fields: "Original File" and "Modified File."
- Select Excel Files: Click "Choose File" for each input and select your
.xlsxfiles. - Generate Report: Click the "Compare Files" button.
- View Report: The application will process the files and display the diff report directly on the page.
- Download Report: You will also find a link to download the full HTML report for future reference.
DiffXcel/
├── app.py # The main Flask application file
├── requirements.txt # Python dependencies
├── uploads/ # Directory for temporarily storing uploaded Excel files
├── reports/ # Directory for storing generated HTML reports
└── templates/
└── index.html # The main HTML template for the web interface
Contributions are welcome! If you have suggestions for improvements, bug fixes, or new features, please feel free to:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a Pull Request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
