Skip to content

HackettLai/excel-differ

Repository files navigation

Excel Differ πŸ“Š

A web-based Excel file comparison tool that helps you identify differences between two Excel files quickly and easily. Runs completely in your browser with no server uploads required.

Excel Differ License Static Badge

Upload Interface Sheet Selection Unified Diff View
Drag and drop Excel files to upload Select sheets from dropdown menus View differences in unified table with color-coded changes

Features ✨

  • πŸ“ Drag & Drop Support - Simply drag and drop Excel files to compare
  • πŸ” Unified Table View - View differences in a single unified table with old/new row indices
  • 🎯 Smart Column Matching - Intelligently matches columns by header content, not position
  • πŸ“Š Cell-Level Diff - Highlights individual cell changes with old β†’ new value display
  • πŸ”„ Column Reordering Handling - Correctly matches columns even when reordered (won't falsely report as added/deleted)
  • 🎯 Change Navigation - Jump between changes with Previous/Next buttons or keyboard shortcuts (P/N)
  • πŸ–±οΈ Click-to-Navigate - Click any changed cell to jump to that change
  • πŸ“ Visual Change Counter - Track your position through changes (e.g., "5 / 23")
  • πŸ’‘ Visual Indicators - Color-coded cells for easy identification of changes
  • πŸ”’ 100% Local - All processing happens in your browser, no data leaves your device
  • πŸš€ No Server Required - Runs entirely client-side

Demo 🎬

Live Demo

What's New in Version 2.0.0 πŸŽ‰

Major Changes

  • Unified Table View: Replaced side-by-side comparison with a single unified table
  • Old/New Row Indices: Each row shows both its old (File A) and new (File B) row numbers
  • Smart Column Matching: Columns are matched by header content, not position
    • Handles column reordering correctly
    • Detects truly added/deleted columns
    • Preserves column relationships even when columns are moved
  • Enhanced Cell Display: Modified cells show "old value β†’ new value" inline
  • Click-to-Navigate: Click any changed cell to jump to that change in the navigation sequence
  • Improved Change Detection: More accurate detection of column additions/deletions

Breaking Changes from v1.x

  • Removed synchronized scrolling (replaced with unified table)
  • Removed side-by-side sheet view (replaced with single table view)
  • Removed sheet rename detection (simplified to focus on content comparison)
  • Changed sheet selection workflow (now manual selection from dropdowns)

Supported File Formats πŸ“‹

  • .xlsx - Excel 2007+ files
  • .xls - Excel 97-2003 files

File Size Limit: 50MB per file

Getting Started πŸš€

Prerequisites

No installation required! Just a modern web browser:

  • Chrome (recommended)
  • Firefox
  • Safari
  • Edge

Installation

  1. Clone the repository:
git clone https://github.com/HackettLai/excel-differ.git
cd excel-differ
  1. Open index.html in your web browser:
# On macOS
open index.html

# On Linux
xdg-open index.html

# On Windows
start index.html

That's it! No build process or dependencies to install.

Usage πŸ“–

Basic Workflow

  1. Upload Files

    • Click "Select File" or drag & drop your Excel files into the upload areas
    • File A: Original/older version
    • File B: New/updated version
  2. Start Comparison

    • Click the "Start Comparing" button
    • Wait for files to be parsed and compared
  3. Select Sheets to Compare

    • If sheets with matching names are found, they'll be auto-selected
    • Otherwise, manually select sheets from the dropdowns
    • Click "Compare" to view differences
  4. Review Differences

    • View all changes in a unified table
    • See old/new row indices for each row
    • Modified cells show "old value β†’ new value"
    • Added columns marked with green header (+B)
    • Deleted columns marked with red header (βˆ’D)
  5. Navigate Changes

    • Click "Previous" or "Next" buttons to jump between changes
    • Use keyboard shortcuts: P for previous, N for next
    • Click directly on any changed cell to navigate to it
    • Track your position with the change counter (e.g., "5 / 23")

Understanding the Results

Column Headers (Two Rows)

  • Row 1: Column letters with indicators
    • Normal columns: A, B, C
    • Added columns: +B (green background)
    • Deleted columns: βˆ’D (red background)
  • Row 2: Header content
    • Shows actual header text from Excel
    • (Blank Column) for columns without headers

Row Indices

  • Old Column: Row number in File A (or - if row was added)
  • New Column: Row number in File B (or - if row was deleted)

Cell Highlighting

  • 🟒 Green Background - Cell in added column or added row
  • πŸ”΄ Red Background - Cell in deleted column or deleted row
  • 🟑 Yellow Background - Cell value was modified (shows old β†’ new)
  • βšͺ White Background - Unchanged cell

Cell Content Display

  • Modified cells: old value β†’ new value
  • Empty cells: Shown as Blank in italic gray text
  • Normal cells: Display current value

Project Structure πŸ“

excel-differ/
β”œβ”€β”€ index.html              # Main HTML file
β”œβ”€β”€ styles.css              # Styling and layout
β”œβ”€β”€ js/
β”‚   β”œβ”€β”€ main.js            # Application entry point and controller
β”‚   β”œβ”€β”€ fileHandler.js     # File upload, drag-and-drop, validation
β”‚   β”œβ”€β”€ excelParser.js     # Excel parsing using SheetJS
β”‚   β”œβ”€β”€ diffEngine.js      # Core comparison algorithm
β”‚   β”œβ”€β”€ diffViewer.js      # Unified table renderer and navigation
β”‚   └── copyright.js       # Copyright year management
└── README.md              # This file

Technologies Used πŸ› οΈ

  • Pure JavaScript (ES6+) - No frameworks, vanilla JS with modules
  • SheetJS (xlsx) - Excel file parsing
  • HTML5 - Modern web standards
  • CSS3 - Styling, animations, and responsive design
  • File API - Browser-native file handling
  • Keyboard API - Keyboard shortcut support

Browser Compatibility 🌐

Browser Version Status
Chrome 90+ βœ… Fully Supported
Firefox 88+ βœ… Fully Supported
Safari 14+ βœ… Fully Supported
Edge 90+ βœ… Fully Supported

Features in Detail πŸ”¬

Smart Column Matching

The tool matches columns by header content, not position:

  • Header-Based Matching: Columns with identical header text are matched
    • Example: If "Email Address" moves from column G to H, it's still matched correctly
  • Reordering Tolerance: Column position changes don't trigger false positives
    • Cells are compared based on what column they logically belong to
    • Reordered columns are NOT marked as added/deleted
  • True Add/Delete Detection: Only reports genuine column additions/deletions
    • Added column: Header exists in File B but not in File A
    • Deleted column: Header exists in File A but not in File B

Change Navigation

Quickly navigate through all cell-level changes:

  • Previous/Next Buttons - Navigate sequentially through changes
  • Keyboard Shortcuts - Press P for previous, N for next
    • Only active when not typing in input fields
    • Works globally across the page
  • Click Navigation - Click any changed cell to jump to that change
    • Updates current position in navigation sequence
    • Automatically scrolls cell into view
  • Change Counter - Shows current position and total changes (e.g., "5 / 23")
    • Updates dynamically as you navigate
    • Displays 0 / 0 when no changes exist
  • Visual Highlight - Briefly highlights the target cell when navigating
    • 2-second highlight with CSS animation
    • Smooth scroll with centering

Row Matching

Rows are matched using column A as the primary key:

  • Key-Based Matching: Uses column A value to identify matching rows
    • Example: Row with "John Doe" in column A matches across files
  • Fallback Keys: For rows without column A values, uses position-based keys
    • old-{index} for File A rows
    • new-{index} for File B rows
  • Add/Delete Detection:
    • Added row: Key exists in File B but not in File A
    • Deleted row: Key exists in File A but not in File B

Performance Optimizations

  • Efficient diff algorithm with minimal memory footprint
  • Lazy DOM manipulation for large spreadsheets
  • Optimized scroll event handling
  • Smart cell collection for navigation

How It Works πŸ”

Excel Differ uses a multi-step pipeline to detect changes:

  1. File Parsing - Reads Excel files using SheetJS into JavaScript objects
  2. Column Matching - Matches columns by header content (not position)
  3. Row Matching - Matches rows using Column A as unique identifier
  4. Cell Comparison - Compares matched cells and detects modifications

Key Features:

  • βœ… Handles column reordering (matches by header name)
  • βœ… Handles row reordering (matches by Column A value)
  • βœ… Detects added/deleted columns and rows
  • βœ… Highlights modified cells with old β†’ new display

Important Design Decision:

  • Row matching relies on Column A values - This enables accurate detection of row reordering, but requires Column A to contain stable unique identifiers
  • If Column A values change, rows cannot be matched correctly (see Limitations for details)

πŸ“– Read detailed technical documentation β†’

Keyboard Shortcuts ⌨️

Key Action Description
P Previous Change Jump to previous changed cell
N Next Change Jump to next changed cell

Note: Shortcuts are disabled when typing in input/textarea/select elements

Limitations ⚠️

Row Matching Dependency

Issue: Rows are matched using Column A values only

Impact:

  • If Column A values change between files, rows will be incorrectly matched
  • All cells in that row may show as modified even if unchanged

Example:

File A: | 1 | peter | 34 |
File B: | 2 | peter | 34 |

Result: Treated as different rows
Shows: "1 β†’ 2" and all cells modified ❌

Solutions:

  1. βœ… Use stable IDs in Column A (employee ID, product code, order number)
  2. βœ… Add an ID column if your data doesn't have one
  3. βœ… Pre-sort both files by the same key before comparison
  4. ⚠️ Avoid using auto-incremented numbers that change between versions

File Size Limit

Issue: Maximum 50MB per file

Reason: Browser memory limitations

Solutions:

  1. Split large files into smaller chunks
  2. Filter to relevant date ranges before comparison
  3. Remove unnecessary columns before uploading

What's NOT Compared

  • ❌ Cell formatting (colors, fonts, borders)
  • ❌ Formulas (only computed values)
  • ❌ Charts and images
  • ❌ Merged cell information
  • ❌ Data validation rules
  • ❌ Conditional formatting rules

Alternative: Use Excel's built-in "Compare and Merge Workbooks" for format comparison

Use Cases πŸ’Ό

Perfect For

  • Version Control: Compare different versions of Excel reports
  • Data Auditing: Verify data changes in financial spreadsheets
  • Quality Assurance: Validate data migrations or transformations
  • Collaboration: Review changes made by team members
  • Configuration Management: Track changes in Excel-based config files

Not Suitable For

  • Format Comparison: Use Excel's built-in compare for formatting changes
  • Large Dataset Analysis: Consider database tools for millions of rows
  • Real-Time Collaboration: Use Google Sheets or Excel Online instead
  • Formula Debugging: Use Excel's formula auditing tools

Troubleshooting πŸ”§

Common Issues

Files won't upload

  • Check file size (must be under 50MB)
  • Ensure file format is .xlsx or .xls
  • Try re-saving the file in Excel

Comparison is slow

  • Large files may take 10-30 seconds to process
  • Close other browser tabs to free up memory
  • Try comparing smaller sections of data

Changes not detected

  • Ensure both files have matching sheet names
  • Check that column headers match exactly
  • Verify data types are consistent

Navigation buttons disabled

  • No changes detected in selected sheets
  • Try selecting different sheets to compare

Contributing 🀝

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Use ES6+ JavaScript with modules
  • Follow existing code structure and naming conventions
  • Add comprehensive comments for complex logic
  • Test with various Excel file formats and sizes
  • Ensure browser compatibility

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments πŸ™

  • SheetJS for the excellent Excel parsing library
  • Inspired by diff tools like Beyond Compare, WinMerge, and Git diff
  • Built with assistance from Claude AI (Anthropic)

Support πŸ’¬

If you encounter issues or have questions:


⭐ If you find this tool useful, please consider giving it a star on GitHub!

Made with ❀️ by Hackett.Lai

About

A web-based Excel file comparison tool that helps you identify differences between two Excel files quickly and easily.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published