Comparison of excel files

Posted by: srinivas.suravarapu on 8 May 2025, 3:02 am EST

  • Posted 8 May 2025, 3:02 am EST

    Hi Is there any method available in DSExcel.Net to compare two excel files and produce a track changes output as one excel file , Aspose Cells/Words has this capability

    Infact even if this is something achieveable in Spreadjs it will be fine

    Thank you

  • Posted 13 May 2025, 2:30 am EST

    Hi,

    Apologies for the delay caused over the weekend.

    Regarding your query, there is currently no built-in API method in DsExcel.NET that directly compares two Excel workbooks and generates a tracked-differences output. However, it is possible to manually compare individual elements—such as cell values, styles, and formulas—across two workbooks. We’ve raised this enhancement request with our internal team and will keep you updated on any progress.

    Internal Tracking ID: DOCXLS-12428

    Additionally, based on our research, Aspose.Cells do not offer a dedicated Compare method in its API to produce a tracked-differences Excel output. They do provide an online demo for Excel file comparison, but this feature is not available as part of the core API.

    We will update you as soon as we get any update on this from development side.

    Kind Regards,

    Prabhat Sharma

  • Posted 14 May 2025, 1:16 am EST - Updated 14 May 2025, 1:21 am EST

    Hi Prabhat

    Thanks your reply, appreciate your reply, the aspose compare is not great for structural differences anyways, so I wouldnt waste time on it

    I can do a json compare each individual json file in the js zip and determine which sheets changed and what changed, if the json files inside the sjs zip had additional properties that spreadjs does not understand will it complain and will it not load? I wanted to understand if we can add json attributes which identify changes and if there is any kind of json validation built into spreadjs which will fail to load the spreadsheets

    When we want to display the changes - Let us say a cell had value 10 , this was changed 20 then we would show it as in the screenshot attached,

    is there someway i can show two values with different styles in a cell, is there a notion of text runs inside cells which can have different styles in DSExcel? which can be used to drive different styles and display them in spreadjs

    This is a loaded question, but just wanted to see if you had any thoughts on this

  • Posted 15 May 2025, 7:18 am EST - Updated 15 May 2025, 7:24 am EST

    Hi,

    Yes, you can safely add your own custom JSON properties inside the .sjs package. However, the product will ignore any unknown properties and only parse the fields it is bound to. So, your metadata - used for tracking or highlighting changes - will not cause load failures or validation errors, as long as the file remains structurally sound.

    However, we recommend you write your custom logic for comparing two workbooks in DsExcel.NET as the comparison logic can be a bit too broad and you can write the logic specific to your comparison requirements. You can refer to the below code snippet that illustrates the comparison of two workbooks and rewrite the cell text as per the screenshot:

    Workbook originalWorkbook = new();
    originalWorkbook.Open("book1.sjs");
    Workbook secondWorkbook = new();
    secondWorkbook.Open("book2.sjs");
    Workbook resultWorkbook = new();
    resultWorkbook.Open("book1.sjs"); // base it off the original
    for (int i = 0; i < originalWorkbook.Worksheets.Count; i++)
    {
        IRange usedRange = originalWorkbook.Worksheets[i].GetUsedRange();
        for (int row = usedRange.Row; row <= usedRange.LastRow; row++)
        {
            for (int col = usedRange.Column; col <= usedRange.LastColumn; col++)
            {
                string originalText = originalWorkbook.Worksheets[i].Cells[row, col].Text;
                string newText = secondWorkbook.Worksheets[i].Cells[row, col].Text;
    
                if (!string.IsNullOrEmpty(originalText) && !string.Equals(originalText, newText))
                {
                    IRange resultCell = resultWorkbook.Worksheets[i].Cells[row, col];
                    resultCell.Clear(); // clear existing content
    
                    IRichText richText = resultCell.RichText;
                    ITextRun oldRun = richText.Add(originalText);
                    oldRun.Font.Color = System.Drawing.Color.Green;
                    oldRun.Font.Strikethrough = true;
    
                    ITextRun newRun = richText.Add(newText);
                    newRun.Font.Color = System.Drawing.Color.Red;
                    newRun.Font.Underline = UnderlineType.Single;
                }
            }
        }
    }
    resultWorkbook.Save("book3.xlsx");

    You can further refer to the attached code sample that uses the above code snippet and generates the required results (see below).

    Additionally, the development team also requires the following details to implement a workbook compartor:

    What values need to be compared - cell values, text, styles, etc?

    Do you also need to compare row height and column widths?

    How to handle situations where the sheets in the two workbooks are different?

    How to store different comparison results?

    Please share a detailed overview of the above scenarios as the comparison is a bit broader concept for the Workbooks and will help us to implement the same in the required direction.

    Please feel free to reach out if you encounter any further issues or require additional guidance.

    Regards,

    Prabhat Sharma.

    CompareWorkbooks.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels